I have got to read and manipulate a cookie that looks like this:
cookiename = 9918430821007~12.00 | 7C9918430831006~3.00 | 7C7501031311309~50.30
The above cookie has 3 values, each separated by "|" Each value is separated by a "~"
The first item(9918430821007) represents a unique product id The second (12.00) represents the amount in usd
I am stuck in the following:
How do i check if the product ID exist when adding a product to a shopping cart(to prevent duplicate entries)?
I have got to make a total $ of all usd values, how to make the total of all these amout pairs (12.00,3.00,50.30..etc)
FYI i am using jquery 1.72 + jquery.cookie.js
Any help would much be appreciated
Thanks
How about something like this ?
var Products = $.cookie('cookiename').split(' | ')
// Products= ['9918430821007~12.00', '7C9918430831006~3.00', '7C7501031311309~50.30']
You could then do this:
Products[0].split('~')[0] // 9918430821007
Products[0].split('~')[1] // 12.00
...or something of that sort. Hope this helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.