add local in previous page
var values ;
function getCurrentproduct ( ){
$w ( ‘#myproductPage’ ). getProduct ()
. then (( product ) => {
**let** productName = product . name ;
values = product . name ;
productDescription = product . description ;
productmainMedia = product . mainMedia ;
totalQuantity = product . pricePerUnit ;
console . log ( ‘Current product:’ , product );
// see example product object below
local . setItem ( “product image” , productmainMedia );
local . setItem ( “Current product” , productName );
})
Next page
$w . onReady ( function () {
myButtonWasClicked ();
export function myButtonWasClicked ( event ){
**let** value = local . getItem ( "Current product" );
**let** images = local . getItem ( "product image" );
displayCartMessage ( value );
display ( images );
}
function displayCartMessage ( value ){
$w ( "#text48" ). text = `The product ${ value } is added to your selection`
}
})
Hi,
Is this all the code from your website?
Your onready does not have an end curly and normal bracked.
What is local?
Add some more information please.
Kind regards,
Kristof
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);
});
}
it will be great if we get the reference for all the field used
If you have a question, please open your own post and describe your issue.
Nopes i dnt have my issues(for now), i was asking the author of post, if author can show the reference fields he used / also opening my own post lol let them solve my previous queries first.