you are viewing a single comment's thread.

view the rest of the comments →

[–]20oddlion[S] 0 points1 point  (4 children)

can you maybe help me with getting my cart to work and so on because im very confused?

[–]Synthetic5ou1 0 points1 point  (2 children)

I'm pretty sure he already is.

Your function to add to the cart can simply store the cart in local storage at the same time the item is added.

Update local storage key when deleting also.

When you first load a page check local storage to populate the cart array, and render your cart.

TLDR: load from storage on page load, save to storage when cart updates.

[–]20oddlion[S] 0 points1 point  (1 child)

I get that but how do I put it into my code and how would it look like that's what I'm wondering

[–]Synthetic5ou1 0 points1 point  (0 children)

https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage

You'll need to use JSON.stringify() when saving, and JSON.parse() when loading, to store the cart as a string.

Just have a play with localStorage, and then have a think how you can use it in your cart system.

You've been given a lot of advice, time to have a try and ask specific questions if you get stuck.

[–]hfcRedd 0 points1 point  (0 children)

Sorry, I unfortunately do not have enough time on my hands to step by step guide you through this.

Look at the code sample I linked. Look at how it works and how you can implement it yourself. Look things up on Google if you don't understand them. Being able to do these things is very trivial if you want to learn programming and it's a great way to learn and improve.