Hi,
I’m having a problem with my cart page not always loading the cart items. Every now and then it displays no cart items.
This is for an HTML cart page where I’m using the following to get items…
document.addEventListener('snipcart.ready', function() {
let cartItems = Snipcart.store.getState().cart.items.items;
...
then I’m looping through to get each item…
itemName = cartItems[i].name;
This works. But not every time. 10% of time no cart items show.
My site is a normal website with HTML pages from PHP templates, it’s not a single page app. In Snipcart Test mode.
How can I solve this? Maybe I should add the items to local browser storage at the time users add them to cart. Then assemble the cart page from local storage data? Is that a bad idea?