SimpleCart JS issue - cart items dropping out

SimpleCart issue

I’m using SimpleCart Javascript-based shopping cart system on a site and have found a major problem which appears to be related to browser cookies and the ability of the code to successfully hold a certain amount of data in the cart.
Basically I can add up to 3 or 4 different items into the cart but if I try to add any more, although it initially says the item has been added and the number of items increments by 1, if I then go to the cart page the item isn’t there- it’s as if it drops out of the cart if I go to the cart page, or indeed any other page.
This happens regardless of the browser being used.
The problem is documented here along with some suggested solutions, which unfortunately didn’t work for me:
http://stackoverflow.com/questions/17604379/shopping-cart-cookies-only-holding-2-5-items
I tried setting the Local Storage method as suggested, and that actually made the issue worse- it dropped every item from the cart and no more could be added.
On further investigation I found that it’s definitely because of the amount of data sent through the browser via a cookie. This is the code from the SimpleCart JS file that sends the item into the cart and is supposed to keep it there unless removed:

function ShelfItem(){
	this.id = "s" + simpleCart.nextId++;
}
ShelfItem.prototype = {
	
	remove : function () {
		simpleCart.Shelf.items[this.id] = null;
	},
	addToCart : function () {
		var outStrings = [],
			valueString,
			field;
			
		for( field in this ){
			if( typeof( this[field] ) !== "function" && field !== "id" ){
				valueString = "";

				switch(field){
					case "price":
						if( this[field].value ){
							valueString = this[field].value;
						} else if( this[field].innerHTML ) {
							valueString = this[field].innerHTML;
						}
						/* remove all characters from price except digits and a period */
						valueString = valueString.replace( /[^(\d|\.)]*/gi , "" );
						valueString = valueString.replace( /,*/ , "" );
						break;
					case "image":
						valueString = this[field].src;
						break;
					case "Thumb_item":
					break;
        			case "Description":
					break;
        			case "description":
					break;
          			/* don't store "thumb" and "description" in the cookie */
					default:
						if( this[field].value ){
							valueString = this[field].value;
						} else if( this[field].innerHTML ) {
							valueString = this[field].innerHTML;
						} else if( this[field].src ){
							valueString = this[field].src;
						} else {
							valueString = this[field];
						}
						break;
				}
				outStrings.push( field + "=" + valueString );
			}
		}
		simpleCart.add( outStrings );
	}
};

I experimented by setting the valueString to null. When I did that, obviously most of the fields didn’t get through into the shopping cart, but I found that now I could add up to 5 different items into the cart.
So the issue seems to be down to the amount of data that the Simple Cart can send through as a cookie.
Has anyone else had this issue with Simple Cart?
Apparently getting the site re-done with a proper ecommerce system is a non-starter as the client won’t pay for it.
Any help appreciated… thanks…

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.