I've created a product tear sheet that utilizes local storage to pass product information onto a new page to be printed. I'm able to successfully bring in all the information I need however if I select new product variants (such as bed size, wood type, etc.) the new product info page doesn't update until I manually refresh my product page.
Is there a way to have my local storage updated when a new variant is selected? I've included a snippet of code to show how I am setting my local storage so hopefully that is helpful.
var variantStore = "variants" + variantId;
var titlePrint = '{{ product.title }}';
var pricePrint = '{{ product.price | money }}';
var imgGet = '{{ product.selected_or_first_available_variant.image }}';
var imgPrint = '{{ product | img_url: '720x720' }}';
var skuPrint = '{{ product.selected_or_first_available_variant.sku }}';
var dimensPrint = '{{ current_variant.barcode }}'.toString();
var descPrint = '{{ product.description }}';
var detailsPrint = '{{ product.selected_variant.metafields.variant.details_specs }}'
var variantPrint = '{{ product.selected_variant.title }}'
localStorage.clear();
function currentProduct() {
// VARIANTS
localStorage.setItem(variantStore, variantPrint);
// console.log('VARIANTS' + localStorage.getItem(variantStore));
// TITLE
localStorage.setItem(titleStore, `{{ product.title }}`.toString());
// console.log('TITLE: ' + localStorage.getItem(titleStore));
// DESCRIPTION
localStorage.setItem(descStore, descPrint);
// console.log('DESC: ' + localStorage.getItem(descStore));
// IMAGE
localStorage.setItem(imgStore, imgPrint);
// console.log('IMAGE: ' + localStorage.getItem(imgStore));
// PRICE
localStorage.setItem(priceStore, pricePrint);
// console.log('PRICE: ' + localStorage.getItem(priceStore));
// SKU
localStorage.setItem(skuStore, skuPrint);
// console.log(localStorage.getItem(skuStore));