Skip to content Skip to sidebar Skip to footer

Implementing Localstorage

Currently working on an e-commerce website, which is my first major project. I am, for the first time, implementing localstorage for the basket date (qty, items etc). What I am try

Solution 1:

You are just setting it to a variable and not updating it in local storage. Also in addToBasket function you need to check the quantity from the local storage and increment it and then set the new quantity to the local storage.

localStorage.setItem("basketData", JSON.stringify({
    basketQty: 1,
    products: []
})); 

You can refer this example. I have created a raw workaround for this you would have an better idea of it

https://jsfiddle.net/3tdn2jrv/


Post a Comment for "Implementing Localstorage"