Jump to content

Empty Shopping Cart in IE only


Recommended Posts

Hi,

 

When I click on the Check Out button in the shopping cart block it leads me to /quick-order, however, in IE it then shows a page with "Your shopping cart is empty.". This only happens in IE, it works fine in Firefox.

 

I have browsed the forum and the Prestashop Forge, and although I've come across some people having the same issue, I haven't found a solution.

 

The Geo location is switched off. Any thoughts on what else it might be?

 

You can see it in action here: http://www.TheCutestStickers.com (when you add a product and click "Check Out" in the cart block it shows the "Your shopping cart is empty" page.

 

Thanks for your help,

 

Michelle

Link to comment
Share on other sites

I am using IE8. I have another website running on Prestashop and don't have the issue there, funnily enough. Especially because I used the above website as a base and copied the Prestashop files to the other one, that ís working.

 

Any thoughts on where I should look?

Link to comment
Share on other sites

Hi Bazze,

 

Thanks for your reply - our posts crossed each other. I'm using IE8. I switched the Ajax feature off, then it worked. Then I switched it on again and now it appears to be working just fine. Could that just be it? Switching it on and off?

 

I'll keep an eye on it, if it starts playing up again I'll be back.

 

Thanks for your help!

 

Michelle

Link to comment
Share on other sites

Hi Bazze,

 

Thanks for your reply - our posts crossed each other. I'm using IE8. I switched the Ajax feature off, then it worked. Then I switched it on again and now it appears to be working just fine. Could that just be it? Switching it on and off?

 

I'll keep an eye on it, if it starts playing up again I'll be back.

 

Thanks for your help!

 

Michelle

 

I thought that there could be some kind of JavaScript issue. Have you done any changes to the JavaScript? IE is more sensitive to faulty JavaScript coding, as an example:

 

$.ajax({
   url: "http://domain.com",
   //...<other settings>...
   success: function(data) {
    //stuff here
   },
   errror: function() {
    //stuff here
   },
});

 

The script above will most probably fail in some IE versions because of the , (comma) after the error function which shouldn't be there. Firefox will ignore this coding error and continue as it wasn't there.

Link to comment
Share on other sites

Hi Bazze,

 

I might have edited the JavaScript, to be honest I've made quite a few customizations, I can't remember them all. Which file would that be? product.js? It appears to be working again now though.

 

Are you good with JavaScript? I'm having another issue (see this post: http://www.prestashop.com/forums/topic/165230-thickbox-images-showing-smaller-than-original-images/page__pid__811946#entry811946 ) , with the pop up images appearing smaller than the original images. Would you be able to assist me there?

 

Michelle

Link to comment
Share on other sites

Hi Bazze,

 

I might have edited the JavaScript, to be honest I've made quite a few customizations, I can't remember them all. Which file would that be? product.js? It appears to be working again now though.

 

Are you good with JavaScript? I'm having another issue (see this post: http://www.prestasho...946#entry811946 ) , with the pop up images appearing smaller than the original images. Would you be able to assist me there?

 

Michelle

 

Hmm if you try to remember where and what you edited I can take a look at it, but it's just too much to go thru your js files without knowing a bit more where to look!

 

It works now you say, maybe it works on certain pages and doesn't work on other pages? For example, the product.js file is only included on the product page and not anywhere else. So if it's on the (single) product page it doesn't work, the issue is probably in the product.js file.

 

I'll have a look at your other thread!

Link to comment
Share on other sites

This is more than likely your problem, http://forge.prestas...owse/PSCFI-4713 Why the people at prestashop close bugs without fixing them, I dunno.

 

That's right, I've found more similar issues over there, like this one: http://forge.prestashop.com/browse/PSCFI-3421 Also, with more people reporting having the same problem, but no fix.

 

 

In exactly which version of IE8 does this bug occur? 8.x.x?

 

I have version 8.0.7600.16385

It is still working fine now, after I switched Ajax off and on. So could that just be the fix?

Link to comment
Share on other sites

  • 5 months later...

I am having the exact same problem as lettersets. I tried disabling and re-enabling AJAX but this didn't work (by that you mean just configuring the cart module by saving 'disabled' and then saving 'enabled'?)

 

I have not edited the code of my java at all. I am running a fresh install of 1.5.1 and using internet explorer 9.

 

The cart works fine in chrome, just having the problem in IE. My site is www.ringfraternity.com/shop

 

Any help would be greatly appreciated.

Link to comment
Share on other sites

  • 2 weeks later...

Just want to share how to fix the problem with cart "Cart always empty" when check out or refresh page.

Try this one, remove "www" from your site name. in your back office go to:

 

(preferences --> SEO & URLs --> set shop url --> then remove "www" from your site name)

 

if you used "url rewriting" please deactive it first, then clear your cache, now try to make check out in your own shop. its 100% always work for me..!!

 

another option is redirect domain.com to www.domain.com in the .htaccess

Link to comment
Share on other sites

  • 4 weeks later...

Hi guys

 

I found a way to fix this issue.

After many hours of trace code I found that cookie is being overwrited when ajax cart is enabled.

This is the cause that the order was lost and cart appears empty and this is the explaination :

 

- Supose the first time you visit the shop, no cookies are on your browser yet.

- When you add a product using ajax cart ( using a ajax_add_to_cart_button class button ) you are using this piece of code :

 

		$('.ajax_add_to_cart_button').unbind('click').click(function(){
		var idProduct =  $(this).attr('rel').replace('ajax_id_product_', '');
		if ($(this).attr('disabled') != 'disabled')
			ajaxCart.add(idProduct, null, false, this);
		return false;
	});

 

So you call ajaxCart.add() when you add a product.

Inside ajaxCart.add() there are two significant actions that modify your cookie:

 

first one is expand the cartblock. Basically open the cart box and send an ajax petition to include 'expand' parameter into your cookie

 

	if ($('#cart_block #cart_block_list').hasClass('collapsed'))
		this.expand();

 

 

and inside expand() the expand action the visual box slidedown :

 

 

				$('#'+parentId+' #cart_block #cart_block_summary').slideUp(200, function(){
				$(this).addClass('collapsed').removeClass('expanded');
				$('#'+parentId+' #cart_block #cart_block_list').slideDown({
					duration: 600,
					complete: function(){$(this).addClass('expanded').removeClass('collapsed');}
				});
			});

 

and store cookie value :

				$.ajax({
				type: 'GET',
				url: baseDir + 'modules/blockcart/blockcart-set-collapse.php',
				async: true,
				data: 'ajax_blockcart_display=expand' + '&rand=' + new Date().getTime()
			});	

 

Second one, adds the product in your cart.

 

 

		$.ajax({
		type: 'POST',
		url: baseDir + 'cart.php',
		async: true,
		cache: false,
		dataType : "json",
		data: 'add=1&ajax=true&qty=' + ((quantity && quantity != null) ? quantity : '1') + '&id_product=' + idProduct + '&token=' + static_token + ( (parseInt(idCombination) && idCombination != null) ? '&ipa=' + parseInt(idCombination): ''),
		success: function(jsonData,textStatus,jqXHR)
		{
		....
		....			
		....

		});

 

Well, tracing the code using phpfire I could see that requests are sent in this order :

 

1.- blockcart-set-collapse.php

2.- cart.php

 

In cases that works fine I got the return of the request in same order, but when cart gets empty, I reicived cart.php firt and then blockcart-set-collapse.php

 

This means that blockcart-set-collapse.php is requested without id_cart cookie value, so return a cookie without id_cart.

So id_cart is generated in cart.php call, and blockcart-set-collapse.php returns the cookie after cart.php, so the id_cart is not preserved because is being overwritted.

 

 

There are few ways to fix this :

 

 

1.- At ajaxCart.add() disable this.expand() , avoid to made ajax call

2.- at ajaxCart.expand() put ajax request before slideDown() call

3.- The second point and made ajaxcall syncronious setting async : false

 

				$.ajax({
				type: 'GET',
				url: baseDir + 'modules/blockcart/blockcart-set-collapse.php',
				async: false,
				data: 'ajax_blockcart_display=expand' + '&rand=' + new Date().getTime()
			});	

 

 

Another way to fix this, is to have ever a id_cart at cookie.

I'm not sure but I think at previous prestashop ( 1.3.x) id_cart was stored at cookie in the first request.

At Prestashop 1.4.x cart is generated at FrontControllerCore::init() but not saved even asigned to the cookie.

Reviewing the code quickly, I see that the id_cart is asigned when a product is added to the cart.

So another solution could be to store a cart in cookies ever.

 

 

 

I hope this could help you to fix your shops !

 

 

PounStudio !

http://www.pounstudio.com

 

http://www.senin.org/2012/11/22/prestashop-fix-empty-cart-cookie-overwritted/

Edited by jsenin (see edit history)
Link to comment
Share on other sites

  • 2 years later...
  • 8 months later...
  • 3 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...