I must say, that your code looks totaly chaotic.
You do not use the right code-structure and like it seems, also your code it not right.
What exactly are you trying to do, using this code?
I thinnk you have found somewhere some codes, which you have tried to combine and generate your own one (without success).
Please describe, what is your aim.
Please describe your setup.
Did you also show the whole code? Some parts are incomplete…for example…
let productDescription = product.description;
let productmainMedia = product.mainMedia;
let totalQuantity = product.pricePerUnit;
Your variables are declared anywhere.
Why do you need Wix-Storage, what for? (yes i see a PREVIOUS/NEXT-function), but you are sure, that you need Wix-Storage?
Please give more details, as Kristof already asked for.
I would suggest you to start with the following one…
As i know, you are working on the PRODUCTS-PAGE (a special page).
So lets get the current product and all its data of the current product-page & and also lets set 2 variables in wix-storage (local)…
import wixStorage from 'wix-storage';
$w.onReady(function() {console.log("Page is ready now!");
getCurrentproduct();
});
function getCurrentproduct(){console.log("Get-Product-Process running ...");
$w('#myproductPage').getProduct()
.then((product) => {console.log('Current product:' , product);
let productName = product.name; console.log(productName);
let productDescription = product.description; console.log(productDescription);
let productMainMedia = product.mainMedia;
let totalQuantity = product.pricePerUnit; console.log(totalQuantity);
wixStorage.local.setItem("productImage", productMainMedia);
wixStorage.local.setItem("currentProduct", productName);
});
}