Note that there are some explanatory texts on larger screens.

plurals
  1. POShopping cart: Cookies only holding 2 - 5 items
    primarykey
    data
    text
    <h2>This is likely an easy fix (easy +200 reputation), for someone who has javascript skills.</h2> <h2>Demo of problem: <a href="http://shoppingcart-bthub.blogspot.com/" rel="nofollow">http://shoppingcart-bthub.blogspot.com/</a> Just add all the items to the cart and click refresh to see the problem with the cookies.</h2> <p>Everything works correctly, except the part of the code that handles cookies for the items that get added to the shopping cart. For some reason, it only holds 2 -5 items, depending on the broswer:</p> <p>Google Chrome - only holds 2 items (all other items in shopping cart disappear after page reload)</p> <p>Firefox - 4 items total</p> <p>Safari - 4</p> <p>Internet Exploer - 5</p> <p>The javascript in the demo: <a href="http://shopppingcart.googlecode.com/files/simplecart.js" rel="nofollow">http://shopppingcart.googlecode.com/files/simplecart.js</a></p> <p>The part of the javascript link above that is coded to handle cookies:</p> <pre><code> /*** data storage and retrival ****/ /* load cart from cookie */ me.load = function () { var me = this; /* initialize variables and items array */ me.items = {}; me.total = 0.00; me.quantity = 0; /* retrieve item data from cookie */ if( readCookie('simpleCart') ){ var data = unescape(readCookie('simpleCart')).split('++'); for(var x=0, xlen=data.length;x&lt;xlen;x++){ var info = data[x].split('||'); var newItem = new CartItem(); if( newItem.parseValuesFromArray( info ) ){ newItem.checkQuantityAndPrice(); /* store the new item in the cart */ me.items[newItem.id] = newItem; } } } me.isLoaded = true; }; /* save cart to cookie */ me.save = function () { var dataString = ""; for( var item in this.items ){ dataString = dataString + "++" + this.items[item].print(); } createCookie('simpleCart', dataString.substring( 2 ), 30 ); }; </code></pre> <h2>To test the full live code:</h2> <p>For the complete live template with all the codes, open a free blog at blogger.com and download the XML template here to upload into blogger: <a href="http://www.bloggermint.com/2011/05/shopping-cart-blogger-template/" rel="nofollow">http://www.bloggermint.com/2011/05/shopping-cart-blogger-template/</a> The free download is in the left-hand sidebar. Also follow the intructions on that page to get it woking in blogger.com</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload