So basically I'm trying to make a very simple add to cart button.
You click, you can continue "browsing" and when you click to go to the cart it will be there in the format I have it set up in.
I don't exactly need help with having it appear with the right text but mostly with cloning it and then appearing in a entirely different document.
I've tried cloneNode, but that simply appears on the same document.
If you know of any functions/way's to help that would help me a lot.
CodePudding user response:
You can achieve this in many ways. From storing a value as a parameter in an URL, using localStorage, cookies, make your own state manager or use Redux, React Context API, MobX, etc.
Try with localStorage API.
localStorage.setItem('cartProduct', cartProduct)
then you can read it with
localStorage.getItem('cartProduct)
https://www.taniarascia.com/how-to-use-local-storage-with-javascript/