I’m having a lot of success with wix code and finding the experience very rewarding! But I have came across another area that has stumped me… I have been using session storage to transfer data from one dynamic page to another, this is successful, the issue is that there are 4 buttons on my page and depending on what button is clicked then this will store the relevant data i.e. the date of the course. This all works fine as I can see on the console log on this page.
The area that I’m trying to work out is how do I get the specific data to read on the new page (details and payment) depending on what button is pressed? I have played around with the code and came up with the following, but have came to a brick wall… Is anyone able to help?
import {session} from 'wix-storage';
$w.onReady(function () {
if (session.getItem === 'coursetitle','durationOne','dateOne', 'priceOne'){
let title = session.getItem('coursetitle');
$w('#coursetitle').text = title;
$w('#coursetitletxt').value = title;
let duration1 = session.getItem('durationOne');
$w('#durationtxt').value = duration1;
let date1 = session.getItem('dateOne');
$w('#coursestartdatetxt').value = date1;
let price1 = session.getItem('priceOne');
$w('#pricetxt').value = price1;
}
else if (session.getItem === 'coursetitle','durationTwo','dateTwo', 'priceTwo'){
let title = session.getItem('coursetitle');
$w('#coursetitle').text = title;
$w('#coursetitletxt').value = title;
let duration2 = session.getItem('durationTwo');
$w('#durationtxt').value = duration2;
let date2 = session.getItem('dateTwo');
$w('#coursestartdatetxt').value = date2;
let price2 = session.getItem('priceTwo');
$w('#pricetxt').value = price2;
}
else if (session.getItem === 'coursetitle','durationThree','dateThree', 'priceThree'){
let title = session.getItem('coursetitle');
$w('#coursetitle').text = title;
$w('#coursetitletxt').value = title;
let duration3 = session.getItem('durationThree');
$w('#durationtxt').value = duration3;
let date3 = session.getItem('dateThree');
$w('#coursestartdatetxt').value = date3;
let price3 = session.getItem('priceThree');
$w('#pricetxt').value = price3;
}
else if (session.getItem === 'coursetitle','durationFour','dateFour', 'priceFour'){
let title = session.getItem('coursetitle');
$w('#coursetitle').text = title;
$w('#coursetitletxt').value = title;
let duration4 = session.getItem('durationFour');
$w('#durationtxt').value = duration4;
let date4 = session.getItem('dateFour');
$w('#coursestartdatetxt').value = date4;
let price4 = session.getItem('priceFour');
$w('#pricetxt').value = price4;
}
else session.clear();
});