dev09
asked on
localStorage - get values
Hi all,
I have 'localStorage' data from an existing website cart that is displaying in the following format:
I used this code to give me the above:
How do i go about extracting the item totals of:
- quantity
- cbm (cubic meters)
- weight
I know it will need to loop through the localStorage but just not sure how too.
Anyone got some experience with this and a super easy solution?
Thanks a heap!!
I have 'localStorage' data from an existing website cart that is displaying in the following format:
{"SCI-1":{"quantity":1,"id":"SCI-1","price":50,"name":"ABC","cbm":"0.000001","weight":"0.1"},"SCI-2":{"quantity":1,"id":"SCI-2","price":100,"name":"DEF","cbm":"0.000001","weight":"0.1"},"SCI-3":{"quantity":1,"id":"SCI-3","price":50,"name":"GHI","cbm":"0.000001","weight":"0.1"}}
I used this code to give me the above:
var result = localStorage["cartData"];
console.log(result);
How do i go about extracting the item totals of:
- quantity
- cbm (cubic meters)
- weight
I know it will need to loop through the localStorage but just not sure how too.
Anyone got some experience with this and a super easy solution?
Thanks a heap!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect, thanks!!
Then looping throw the first level of associative properties, and getting direct .quantity values from those objects.
Something like this:
Open in new window