Jump to content

My cart does not work 1.6


Recommended Posts

My cart does not work. yesterday I installed the new 1.6 full version. Yesterday worked on the basket, it is now not working. if i add the product to  shopping cart and go check out there is empty...

 

another problem: I, as a customer, I can not log out, can not detect

 

I did re-install the shopping cart module, but did not help

 


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

I am also  having trouble.  I have just recently set up this cart.  I have been working to get it finished, but upgraded to 1.6 and now I cannot log in.  No matter how many times Iog in, the log in page does not change.  The log in button indicates no one is logged in as well.

Link to comment
Share on other sites

I took my store off maintenance.  the more I look at it, the more I discover.  

 

1. I can only log in as a customer on internet explorer. Firefox and chrome authentication are not working for customers.  All three seem to work for the admin dashboard.

 

 

Link to comment
Share on other sites

I was able to log in with chrome today, but not mozilla.  Also in Mozilla my cart shows empty after I add a product to it.  It works better in chrome, best in internet explorer.  

 

Another problem is that the colon is missing from the SSL address so it reads http//www etc. which of course does not work at all.  Please help.

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

I'm having the same problem.  URL: http://www.mylocketoflife.com/shop

 

Time is critical on this.


I just discovered the when I look at the backoffice in, 'Customers>Shopping Carts' the orders are showing.  However, when a customer tries to checkout, they're told their cart is empty.


SOLVED!  Go to 'Modules' and click on the 'Cart Block' module.  Select 'NO' for ajax cart.

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

Another problem that I am having is some of the modules are not saving. The "Contact Information Block" isn't working.  I configure the block and save it. the info does not show up and when I go back into the block, it is empty.   This is also the problem with the other "content block" and the "social networking block"  module. The info is not saving on any of them.

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

By the way, I used a different computer and I have been able to log in and my cart contents stayed put.  So it seems very inconsistent.  Sometimes it works and sometimes not, depending on the computer.  My home computer is a desk top. My work computer (where the log in and cart contents did not work) was a laptop.  Not sure if that makes a difference or is just a coincidence.  

Link to comment
Share on other sites

Hi djmila, can you explain this issue a bit more? It doesn't work on touchscreens in Windows 8? The add to cart?

 

In my chrome (ver. 33.0.1750.154) I enabled these: #touch-events and   #touch-optimized-ui

in chrome flags

and the result was, that hover effect (and click) in Cart at the top does not work at all and there is no way I can go to my current cart.

cart.PNG

 

when I disabled those flags, everything works just fine

Edited by teromesiranta (see edit history)
  • Like 1
Link to comment
Share on other sites

In my chrome (ver. 33.0.1750.154) I enabled these: #touch-events and   #touch-optimized-ui

in chrome flags

and the result was, that hover effect (and click) in Cart at the top does not work at all and there is no way I can go to my current cart.

cart.PNG

 

when I disabled those flags, everything works just fine

I got the exact same issue here. Its a real pain in the bug.

 

This is how to replicate it (only see this issue in google chrome - using default presta template)

1. Add some product to your cart

2. When the sexy popup box appears tellin you you add to cart was successfull, simply click on "continue shopping"

3. Now you cant proceed to checkout unless you add to cart again and select "proceed to checkout"

 

I hope presta release a bug fix quick. Another CSS bug hack and im going to scream! Presta need to implement prestapatches. quick patch updates instead of waiting 3 months for everything to be fixed.

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

Did you also file a report in the Bug Tracker? Usually the software maintenance people don't check this forum.

Does that bug tracker thing actually get used?

Well those maintainace poeple should add a "Add this topic to bug tracker" and if lots of people add it then presta will see it. Its like a "Like" button for facebook. Presta then can read all the posts in that topic and then reply in the topic. So no need for that hidden bug tracker feature :)

 

ALso, much more activity on forums as opposed to that bug tracker system. Thats my opinon anyway.. Sorry.

Anyway, i will google "prestashop bug tracker" to see where the link is then add it. :P I hope i dont need to sign up to add a bug!

 

[CLICK HERE TO ADD THIS TOPIC TO BUG TRACKER]

- Added 3234 times

(just an example)

Link to comment
Share on other sites

[PARTIALLY SOLVED]

 

I had a crack at this "Add to cart issue"  and fixed the "click" part. So yes, you can actually click the cart button and it works!! I havent figured out the hover fix, but someone else can give it a go. Im not a AJAX master, so the hack might be a bit ugly for some :P

 

Least now I can actually upload my new presta 1.6 site and avoid lots of abandoned carts from chrome users!

 

How to fix:

Open "ajax-cart.js" from "prestashop\themes\default-bootstrap\js\modules\blockcart\" in a editor.

 

Find the following if statement and change its as follows:

-----------------------------------------------------------------

if ('ontouchstart' in document.documentElement)
    {
        $('.shopping_cart > a:first').on('click', function(e){
            chrome_ajax_fix();        /* AJAX CHROME FIX     <<<<< ADD THIS LINE */
            e.preventDefault();
            
        });

---------------------------------------------------------------------

 

Then add the following function at the end of the file:

---------------------------------------------------------------------

/* AJAX CHROME FIX */
function chrome_ajax_fix()
{
ajax.ajaxing = false;
if (status == 'error' || status == 'parsererror') {
    return ajax.error(response, ajax.url);
    }
}

---------------------------------------------------------------------

 

Maybe someone else can get the cart hover to work on chrome :)

Use at your own risk. I have tested it on chrome, firefox and IE and no side effects so far.

Edited by dsc54000 (see edit history)
  • Like 1
Link to comment
Share on other sites

Hello, I have same problem, in Chrome when I click add to cart is adding items but when I click Checkout :"Your shopping cart is empty."

In Internet explorer is working fine.

I have a Prestashop fresh install 1.6.0.5 with "Simplio" template

Does anyone know how to fix this? Is this a bug in prestashop 1.6? because it seems that affects more people...

 

Another issue is: if I change the administrator language, in the modules page appear updates for modules ( in language is english, there are no updates) but if i click "Update all", appear this: 

The following module(s) were upgraded successfully:

  • Användarinformationsblock : 
        Current version: 0.2
  • Bästsäljarblock : 
        Current version: 1.5.1
  • Leverantörsblock : 
        Current version: 1
  • Mitt konto blocket : 
        Current version: 1.2
  • Mitt kontoruta i sidfoten : 
        Current version: 1.3
  • Nya produkter block : 
        Current version: 1.7
  • Snabbsök block : 
        Current version: 1.4
  • Specialblock : 
        Current version: 1.0
  • Taggblock : 
        Current version: 1.1
  • Varukorgsblock : 
        Current version: 1.3
  • Visade produkter block : 
        Current version: 1

 

but has not been updated any module.

If I try to update one by one: 

 

2 fel 

  1. Fel vid extrahering modul (Filen kan vara skadad). (Swedish)
  2. Module blockbanner can't be upgraded:
Edited by silviu_25 (see edit history)
Link to comment
Share on other sites

Hello, I have same problem, in Chrome when I click add to cart is adding items but when I click Checkout :"Your shopping cart is empty."

In Internet explorer is working fine.

I have a Prestashop fresh install 1.6.0.5 with "Simplio" template

Does anyone know how to fix this? Is this a bug in prestashop 1.6? because it seems that affects more people...

Change to the default theme for testing and try the patch I stated above :)

Link to comment
Share on other sites

Thank you for the answer, I tryed with default theme and I have same issue

 

Add to cart is working, checkout is not working

So can you confirm that you actually applied the patch in #22 and then clear the cache?

If when you "Checkout" and then it says "Your shopping cart is emtpy" thats another issue. That means your "Cart" button works!

Reinstall presta shop and test with the default theme. Dont install your other theme till you tested default one!

Link to comment
Share on other sites

So can you confirm that you actually applied the patch in #22 and then clear the cache?

If when you "Checkout" and then it says "Your shopping cart is emtpy" thats another issue. That means your "Cart" button works!

Reinstall presta shop and test with the default theme. Dont install your other theme till you tested default one!

yes I tryed your patch.

also I tryed to move "ajax-cart.js" with patch from default bootstrap theme to simplio theme and is not working

 

here is my ajax-cart.js untouched from my template: 

/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2013 PrestaShop SA
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/

// Retrocompatibility with 1.4
if (typeof baseUri === "undefined" && typeof baseDir !== "undefined")
	baseUri = baseDir;

//JS Object : update the cart by ajax actions
var ajaxCart = {
	nb_total_products: 0,

	//override every button in the page in relation to the cart
	overrideButtonsInThePage : function(){
		//for every 'add' buttons...
		$('.ajax_add_to_cart_button').unbind('click').click(function(){
			var idProduct =  $(this).attr('rel').replace('nofollow', '').replace('ajax_id_product_', '');
			if ($(this).attr('disabled') != 'disabled')
				ajaxCart.add(idProduct, null, false, this);
			return false;
		});
		//for product page 'add' button...
		$('#add_to_cart input').unbind('click').click(function(){
			ajaxCart.add( $('#product_page_product_id').val(), $('#idCombination').val(), true, null, $('#quantity_wanted').val(), null);
			return false;
		});

		//for 'delete' buttons in the cart block...
		$('#cart_block_list .ajax_cart_block_remove_link').unbind('click').click(function(){
			// Customized product management
			var customizationId = 0;
			var productId = 0;
			var productAttributeId = 0;
			var customizableProductDiv = $($(this).parent().parent()).find("div[id^=deleteCustomizableProduct_]");

			if (customizableProductDiv && $(customizableProductDiv).length)
			{
				$(customizableProductDiv).each(function(){
					var ids = $(this).attr('id').split('_');
					if (typeof(ids[1]) != 'undefined')
					{
						customizationId = parseInt(ids[1]);
						productId = parseInt(ids[2]);
						if (typeof(ids[3]) != 'undefined')
							productAttributeId = parseInt(ids[3]);
						return false;
					}
				});
			}

			// Common product management
			if (!customizationId)
			{
				//retrieve idProduct and idCombination from the displayed product in the block cart
				var firstCut = $(this).parent().parent().attr('id').replace('cart_block_product_', '');
				firstCut = firstCut.replace('deleteCustomizableProduct_', '');
				ids = firstCut.split('_');
				productId = parseInt(ids[0]);
				if (typeof(ids[1]) != 'undefined')
					productAttributeId = parseInt(ids[1]);
			}

			var idAddressDelivery = $(this).parent().parent().attr('id').match(/.*_\d+_\d+_(\d+)/)[1];

			// Removing product from the cart
			ajaxCart.remove(productId, productAttributeId, customizationId, idAddressDelivery);
			return false;
		});
	},

	// try to expand the cart
	expand : function(){
		if ($('#cart_block_list').hasClass('collapsed'))
		{
			$('#cart_block_summary').slideUp(200, function(){
				$(this).addClass('collapsed').removeClass('expanded');
				$('#cart_block_list').slideDown({
					duration: 450,
					complete: function(){$(this).addClass('expanded').removeClass('collapsed');}
				});
			});
			// toogle the button expand/collapse button
			$('#block_cart_expand').fadeOut('slow', function(){
				$('#block_cart_collapse').fadeIn('fast');
			});

			// save the expand statut in the user cookie
			$.ajax({
				type: 'POST',
				headers: { "cache-control": "no-cache" },
				url: baseDir + 'modules/blockcart/blockcart-set-collapse.php' + '?rand=' + new Date().getTime(),
				async: true,
				cache: false,
				data: 'ajax_blockcart_display=expand'
			});


		}
	},
	// Fix display when using back and previous browsers buttons
	refresh : function(){
		$.ajax({
			type: 'POST',
			headers: { "cache-control": "no-cache" },
			url: baseUri + '?rand=' + new Date().getTime(),
			async: true,
			cache: false,
			dataType : "json",
			data: 'controller=cart&ajax=true&token=' + static_token,
			success: function(jsonData)
			{
				ajaxCart.updateCart(jsonData);
			},
			error: function(XMLHttpRequest, textStatus, errorThrown) {
				alert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
			}
		});
	},

	// try to collapse the cart
	collapse : function(){

		if ($('#cart_block_list').hasClass('expanded'))
		{
			$('#cart_block_list').slideUp('slow', function(){
				$(this).addClass('collapsed').removeClass('expanded');
				$('#cart_block_summary').slideDown(450, function(){
					$(this).addClass('expanded').removeClass('collapsed');
				});
			});
			$('#block_cart_collapse').fadeOut('slow', function(){
				$('#block_cart_expand').fadeIn('fast');
			});

			// save the expand statut in the user cookie
			$.ajax({
				type: 'POST',
				headers: { "cache-control": "no-cache" },
				url: baseDir + 'modules/blockcart/blockcart-set-collapse.php' + '?rand=' + new Date().getTime(),
				async: true,
				cache: false,
				data: 'ajax_blockcart_display=collapse' + '&rand=' + new Date().getTime()
			});
		}
	},

	// Update the cart information
	updateCartInformation : function (jsonData, addedFromProductPage)
	{
		ajaxCart.updateCart(jsonData);

		//reactive the button when adding has finished
		if (addedFromProductPage)
			$('#add_to_cart input').removeAttr('disabled').addClass('exclusive').removeClass('exclusive_disabled');
		else
			$('.ajax_add_to_cart_button').removeAttr('disabled');
	},

	// add a product in the cart via ajax
	add : function(idProduct, idCombination, addedFromProductPage, callerElement, quantity, wishlist){
		if (addedFromProductPage && !checkCustomizations())
		{
			alert(fieldRequired);
			return ;
		}
		emptyCustomizations();
		//disabled the button when adding to not double add if user double click
		if (addedFromProductPage)
		{
			$('#add_to_cart input').attr('disabled', true).removeClass('exclusive').addClass('exclusive_disabled');
			$('.filled').removeClass('filled');
		}
		else
			$(callerElement).attr('disabled', true);

		if ($('#cart_block_list').hasClass('collapsed'))
			this.expand();
		//send the ajax request to the server
		$.ajax({
			type: 'POST',
			headers: { "cache-control": "no-cache" },
			url: baseUri + '?rand=' + new Date().getTime(),
			async: true,
			cache: false,
			dataType : "json",
			data: 'controller=cart&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)
			{
				// add appliance to wishlist module
				if (wishlist && !jsonData.errors)
					WishlistAddProductCart(wishlist[0], idProduct, idCombination, wishlist[1]);

				// add the picture to the cart
				var $element = $(callerElement).parent().parent().find('a.product_image img,a.product_img_link img');
				if (!$element.length)
					$element = $('#bigpic');
				var $picture = $element.clone();
				var pictureOffsetOriginal = $element.offset();
				pictureOffsetOriginal.right = $(window).innerWidth() - pictureOffsetOriginal.left - $element.width();

				if ($picture.length)
				{
					$picture.css({
						position: 'absolute',
						top: pictureOffsetOriginal.top,
						right: pictureOffsetOriginal.right
					});
				}

				var pictureOffset = $picture.offset();
				var cartBlock = $('#cart_block');
				if (!$('#cart_block')[0] || !$('#cart_block').offset().top || !$('#cart_block').offset().left)
					cartBlock = $('#shopping_cart');
				var cartBlockOffset = cartBlock.offset();
				cartBlockOffset.right = $(window).innerWidth() - cartBlockOffset.left - cartBlock.width();

				// Check if the block cart is activated for the animation
				if (cartBlockOffset != undefined && $picture.length)
				{
					$picture.appendTo('body');
					$picture
						.css({
							position: 'absolute',
							top: pictureOffsetOriginal.top,
							right: pictureOffsetOriginal.right,
							zIndex: 4242
						})
						.animate({
							width: $element.attr('width')*0.66,
							height: $element.attr('height')*0.66,
							opacity: 0.2,
							top: cartBlockOffset.top + 30,
							right: cartBlockOffset.right + 15
						}, 1000)
						.fadeOut(100, function() {
							ajaxCart.updateCartInformation(jsonData, addedFromProductPage);
							$(this).remove();
						});
				}
				else
					ajaxCart.updateCartInformation(jsonData, addedFromProductPage);
			},
			error: function(XMLHttpRequest, textStatus, errorThrown)
			{
				alert("Impossible to add the product to the cart.\n\ntextStatus: '" + textStatus + "'\nerrorThrown: '" + errorThrown + "'\nresponseText:\n" + XMLHttpRequest.responseText);
				//reactive the button when adding has finished
				if (addedFromProductPage)
					$('#add_to_cart input').removeAttr('disabled').addClass('exclusive').removeClass('exclusive_disabled');
				else
					$(callerElement).removeAttr('disabled');
			}
		});
	},

	//remove a product from the cart via ajax
	remove : function(idProduct, idCombination, customizationId, idAddressDelivery){
		//send the ajax request to the server
		$.ajax({
			type: 'POST',
			headers: { "cache-control": "no-cache" },
			url: baseUri + '?rand=' + new Date().getTime(),
			async: true,
			cache: false,
			dataType : "json",
			data: 'controller=cart&delete=1&id_product=' + idProduct + '&ipa=' + ((idCombination != null && parseInt(idCombination)) ? idCombination : '') + ((customizationId && customizationId != null) ? '&id_customization=' + customizationId : '') + '&id_address_delivery=' + idAddressDelivery + '&token=' + static_token + '&ajax=true',
			success: function(jsonData)	{
				ajaxCart.updateCart(jsonData);
				if ($('body').attr('id') == 'order' || $('body').attr('id') == 'order-opc')
					deleteProductFromSummary(idProduct+'_'+idCombination+'_'+customizationId+'_'+idAddressDelivery);
			},
			error: function() {alert('ERROR: unable to delete the product');}
		});
	},

	//hide the products displayed in the page but no more in the json data
	hideOldProducts : function(jsonData) {
		//delete an eventually removed product of the displayed cart (only if cart is not empty!)
		if ($('#cart_block_list dl.products').length > 0)
		{
			var removedProductId = null;
			var removedProductData = null;
			var removedProductDomId = null;
			//look for a product to delete...
			$('#cart_block_list dl.products dt').each(function(){
				//retrieve idProduct and idCombination from the displayed product in the block cart
				var domIdProduct = $(this).attr('id');
				var firstCut =  domIdProduct.replace('cart_block_product_', '');
				var ids = firstCut.split('_');

				//try to know if the current product is still in the new list
				var stayInTheCart = false;
				for (aProduct in jsonData.products)
				{
					//we've called the variable aProduct because IE6 bug if this variable is called product
					//if product has attributes
					if (jsonData.products[aProduct]['id'] == ids[0] && (!ids[1] || jsonData.products[aProduct]['idCombination'] == ids[1]))
					{
						stayInTheCart = true;
						// update the product customization display (when the product is still in the cart)
						ajaxCart.hideOldProductCustomizations(jsonData.products[aProduct], domIdProduct);
					}
				}
				//remove product if it's no more in the cart
				if (!stayInTheCart)
				{
					removedProductId = $(this).attr('id');
					if (removedProductId != null)
					{
						var firstCut =  removedProductId.replace('cart_block_product_', '');
						var ids = firstCut.split('_');

						$('#'+removedProductId).addClass('strike').fadeTo('slow', 0, function(){
							$(this).slideUp('slow', function(){
								$(this).remove();
								// If the cart is now empty, show the 'no product in the cart' message and close detail
								if($('#cart_block dl.products dt').length == 0)
								{
									$("#header #cart_block").stop(true, true).slideUp(200);
									$('#cart_block_no_products:hidden').slideDown(450);
									$('#cart_block dl.products').remove();
								}
							});
						});
						$('#cart_block_combination_of_' + ids[0] + (ids[1] ? '_'+ids[1] : '') + (ids[2] ? '_'+ids[2] : '')).fadeTo('fast', 0, function(){
							$(this).slideUp('fast', function(){
								$(this).remove();
							});
						});
					}
				}
			});
		}
	},

	hideOldProductCustomizations : function (product, domIdProduct)
	{
		var customizationList = $('#customization_' + product['id'] + '_' + product['idCombination']);
		if(customizationList.length > 0)
		{
			$(customizationList).find("li").each(function(){
				$(this).find("div").each(function() {
					var customizationDiv = $(this).attr('id');
					var tmp = customizationDiv.replace('deleteCustomizableProduct_', '');
					var ids = tmp.split('_');
					if ((parseInt(product.idCombination) == parseInt(ids[2])) && !ajaxCart.doesCustomizationStillExist(product, ids[0]))
						$('#' + customizationDiv).parent().addClass('strike').fadeTo('slow', 0, function(){
							$(this).slideUp('slow');
							$(this).remove();
						});
				});
			});
		}

		var removeLinks = $('#' + domIdProduct).find('.ajax_cart_block_remove_link');
		if (!product.hasCustomizedDatas && !removeLinks.length)
			$('#' + domIdProduct + ' span.remove_link').html('<a class="ajax_cart_block_remove_link" rel="nofollow" href="' + baseUri + '?controller=cart&delete=1&id_product=' + product['id'] + '&ipa=' + product['idCombination'] + '&token=' + static_token + '"> </a>');
		if (product.is_gift)
			$('#' + domIdProduct + ' span.remove_link').html('');
	},

	doesCustomizationStillExist : function (product, customizationId)
	{
		var exists = false;

		$(product.customizedDatas).each(function() {
			if (this.customizationId == customizationId)
			{
				exists = true;
				// This return does not mean that we found nothing but simply break the loop
				return false;
			}
		});
		return (exists);
	},

	//refresh display of vouchers (needed for vouchers in % of the total)
	refreshVouchers : function (jsonData) {
		if (typeof(jsonData.discounts) == 'undefined' || jsonData.discounts.length == 0)
			$('#vouchers').hide();
		else
		{
			$('#vouchers tbody').html('');
			for (i=0; i < jsonData.discounts.length; i++)
			{
				if (parseFloat(jsonData.discounts[i].price_float) > 0)
				{
					var delete_link = '';
					if (jsonData.discounts[i].code.length)
						delete_link = '<a class="delete_voucher" href="'+jsonData.discounts[i].link+'" title="'+delete_txt+'"><img src="'+img_dir+'icon/delete.gif" alt="'+delete_txt+'" class="icon" /></a>';
					$('#vouchers tbody').append($(
						'<tr class="bloc_cart_voucher" id="bloc_cart_voucher_'+jsonData.discounts[i].id+'">'
						+ '<td class="quantity">1x</td>'
						+ '<td class="name" title="'+jsonData.discounts[i].description+'">'+jsonData.discounts[i].name+'</td>'
						+ '<td class="price">-'+jsonData.discounts[i].price+'</td>'
						+ '<td class="delete">' + delete_link + '</td>'
						+ '</tr>'
					));
				}
			}
			$('#vouchers').show();
		}

	},

	// Update product quantity
	updateProductQuantity : function (product, quantity) {

		$('#cart_block_product_' + product.id + '_' + (product.idCombination ? product.idCombination : '0')+ '_' + (product.idAddressDelivery ? product.idAddressDelivery : '0') + ' .quantity').fadeTo('fast', 0, function() {
			$(this).text(quantity);
			$(this).fadeTo('fast', 1, function(){
				$(this).fadeTo('fast', 0, function(){
					$(this).fadeTo('fast', 1, function(){
						$(this).fadeTo('fast', 0, function(){
							$(this).fadeTo('fast', 1);
						});
					});
				});
			});
		});
	},


	//display the products witch are in json data but not already displayed
	displayNewProducts : function(jsonData) {

		//add every new products or update displaying of every updated products
		$(jsonData.products).each(function(){
			//fix ie6 bug (one more item 'undefined' in IE6)
			if (this.id != undefined)
			{
				//create a container for listing the products and hide the 'no product in the cart' message (only if the cart was empty)

				if ($('#cart_block dl.products').length == 0)
				{
					$('#cart_block_no_products').before('<dl class="products"></dl>');
					$('#cart_block_no_products').hide();
				}
				//if product is not in the displayed cart, add a new product's line
				var domIdProduct = this.id + '_' + (this.idCombination ? this.idCombination : '0') + '_' + (this.idAddressDelivery ? this.idAddressDelivery : '0');
				var domIdProductAttribute = this.id + '_' + (this.idCombination ? this.idCombination : '0');
				if ($('#cart_block_product_'+ domIdProduct).length == 0)
				{
					var productId = parseInt(this.id);
					var productAttributeId = (this.hasAttributes ? parseInt(this.attributes) : 0);
					var content =  '<dt class="hidden" id="cart_block_product_' + domIdProduct + '">';
					content += '<span class="quantity-formated"><span class="quantity">' + this.quantity + '</span>x</span>';
					// var min = this.name.indexOf(';', 10);
					// var name = (this.name.length > 12 ? this.name.substring(0, ((min - 10) <= 7) ? min : 10) + '...' : this.name);
          var name = (this.name.length > 12 ? this.name.substring(0, 20) + '...' : this.name);
					content += '<a href="' + this.link + '" title="' + this.name + '" class="cart_block_product_name">' + name + '</a>';

					if (typeof(this.is_gift) == 'undefined' || this.is_gift == 0)
						content += '<span class="remove_link"><a rel="nofollow" class="ajax_cart_block_remove_link" href="' + baseUri + '?controller=cart&delete=1&id_product=' + productId + '&token=' + static_token + (this.hasAttributes ? '&ipa=' + parseInt(this.idCombination) : '') + '"> </a></span>';
					else
						content += '<span class="remove_link"></span>';
					if (typeof(freeProductTranslation) != 'undefined')
						content += '<span class="price">' + (parseFloat(this.price_float) > 0 ? this.priceByLine : freeProductTranslation) + '</span>';
					content += '</dt>';
					if (this.hasAttributes)
						  content += '<dd id="cart_block_combination_of_' + domIdProduct + '" class="hidden"><a href="' + this.link + '" title="' + this.name + '">' + this.attributes + '</a>';
					if (this.hasCustomizedDatas)
						content += ajaxCart.displayNewCustomizedDatas(this);
					if (this.hasAttributes) content += '</dd>';

					$('#cart_block dl.products').append(content);
				}
				//else update the product's line
				else
				{
					var jsonProduct = this;
					if($.trim($('#cart_block_product_' + domIdProduct + ' .quantity').html()) != jsonProduct.quantity || $.trim($('#cart_block_product_' + domIdProduct + ' .price').html()) != jsonProduct.priceByLine)
					{
						// Usual product
						if (!this.is_gift)
							$('#cart_block_product_' + domIdProduct + ' .price').text(jsonProduct.priceByLine);
						else
							$('#cart_block_product_' + domIdProduct + ' .price').html(freeProductTranslation);
						ajaxCart.updateProductQuantity(jsonProduct, jsonProduct.quantity);

						// Customized product
						if (jsonProduct.hasCustomizedDatas)
						{
							customizationFormatedDatas = ajaxCart.displayNewCustomizedDatas(jsonProduct);
							if (!$('#customization_' + domIdProductAttribute).length)
							{
								if (jsonProduct.hasAttributes)
									$('#cart_block_combination_of_' + domIdProduct).append(customizationFormatedDatas);
								else
									$('#cart_block dl.products').append(customizationFormatedDatas);
							}
							else
							{
								$('#customization_' + domIdProductAttribute).html('');
								$('#customization_' + domIdProductAttribute).append(customizationFormatedDatas);
							}
						}
					}
				}
				$('#cart_block dl.products .hidden').slideDown(450).removeClass('hidden');

			var removeLinks = $('#cart_block_product_' + domIdProduct).find('a.ajax_cart_block_remove_link');
			if (this.hasCustomizedDatas && removeLinks.length)
				$(removeLinks).each(function() {
					$(this).remove();
				});
			}
		});
	},

	displayNewCustomizedDatas : function(product)
	{
		var content = '';
		var productId = parseInt(product.id);
		var productAttributeId = typeof(product.idCombination) == 'undefined' ? 0 : parseInt(product.idCombination);
		var hasAlreadyCustomizations = $('#customization_' + productId + '_' + productAttributeId).length;

		if (!hasAlreadyCustomizations)
		{
			if (!product.hasAttributes)
				content += '<dd id="cart_block_combination_of_' + productId + '" class="hidden">';
			if ($('#customization_' + productId + '_' + productAttributeId).val() == undefined)
				content += '<ul class="cart_block_customizations" id="customization_' + productId + '_' + productAttributeId + '">';
		}

		$(product.customizedDatas).each(function()
		{
			var done = 0;
			customizationId = parseInt(this.customizationId);
			productAttributeId = typeof(product.idCombination) == 'undefined' ? 0 : parseInt(product.idCombination);
			content += '<li name="customization"><div class="deleteCustomizableProduct" id="deleteCustomizableProduct_' + customizationId + '_' + productId + '_' + (productAttributeId ?  productAttributeId : '0') + '"><a rel="nofollow" class="ajax_cart_block_remove_link" href="' + baseUri + '?controller=cart&delete=1&id_product=' + productId + '&ipa=' + productAttributeId + '&id_customization=' + customizationId + '&token=' + static_token + '"></a></div><span class="quantity-formated"><span class="quantity">' + parseInt(this.quantity) + '</span>x</span>';

			// Give to the customized product the first textfield value as name
			$(this.datas).each(function(){
				if (this['type'] == CUSTOMIZE_TEXTFIELD)
				{
					$(this.datas).each(function(){
						if (this['index'] == 0)
						{
							content += ' ' + this.truncatedValue.replace(/<br \/>/g, ' ');
							done = 1;
							return false;
						}
					})
				}
			});

			// If the customized product did not have any textfield, it will have the customizationId as name
			if (!done)
				content += customizationIdMessage + customizationId;
			if (!hasAlreadyCustomizations) content += '</li>';
			// Field cleaning
			if (customizationId)
			{
				$('#uploadable_files li div.customizationUploadBrowse img').remove();
				$('#text_fields input').attr('value', '');
			}
		});

		if (!hasAlreadyCustomizations)
		{
			content += '</ul>';
			if (!product.hasAttributes) content += '</dd>';
		}
		return (content);
	},


	//genarally update the display of the cart
	updateCart : function(jsonData) {
		//user errors display
		if (jsonData.hasError)
		{
			var errors = '';
			for (error in jsonData.errors)
				//IE6 bug fix
				if (error != 'indexOf')
					errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
			alert(errors);
		}
		else
		{
			ajaxCart.updateCartEverywhere(jsonData);
			ajaxCart.hideOldProducts(jsonData);
			ajaxCart.displayNewProducts(jsonData);
			ajaxCart.refreshVouchers(jsonData);

			//update 'first' and 'last' item classes
			$('#cart_block .products dt').removeClass('first_item').removeClass('last_item').removeClass('item');
			$('#cart_block .products dt:first').addClass('first_item');
			$('#cart_block .products dt:not(:first,:last)').addClass('item');
			$('#cart_block .products dt:last').addClass('last_item');

			//reset the onlick events in relation to the cart block (it allow to bind the onclick event to the new 'delete' buttons added)
			ajaxCart.overrideButtonsInThePage();
		}
	},

	//update general cart informations everywhere in the page
	updateCartEverywhere : function(jsonData) {
		$('.ajax_cart_total').text($.trim(jsonData.productTotal));

		if (parseFloat(jsonData.shippingCostFloat) > 0 || jsonData.nbTotalProducts < 1)
			$('.ajax_cart_shipping_cost').text(jsonData.shippingCost);
		else if (typeof(freeShippingTranslation) != 'undefined')
				$('.ajax_cart_shipping_cost').html(freeShippingTranslation);
		$('.ajax_cart_tax_cost').text(jsonData.taxCost);
		$('.cart_block_wrapping_cost').text(jsonData.wrappingCost);
		$('.ajax_block_cart_total').text(jsonData.total);

		this.nb_total_products = jsonData.nbTotalProducts;

		if (parseInt(jsonData.nbTotalProducts) > 0)
		{
			$('.ajax_cart_no_product').hide();
			$('.ajax_cart_quantity').text(jsonData.nbTotalProducts);
			$('.ajax_cart_quantity').fadeIn('slow');
			$('.ajax_cart_total').fadeIn('slow');

			if (parseInt(jsonData.nbTotalProducts) > 1)
			{
				$('.ajax_cart_product_txt').each( function () {
					$(this).hide();
				});

				$('.ajax_cart_product_txt_s').each( function () {
					$(this).show();
				});
			}
			else
			{
				$('.ajax_cart_product_txt').each( function () {
					$(this).show();
				});

				$('.ajax_cart_product_txt_s').each( function () {
					$(this).hide();
				});
			}
		}
		else
		{
			$('.ajax_cart_quantity, .ajax_cart_product_txt_s, .ajax_cart_product_txt, .ajax_cart_total').each(function(){
				$(this).hide();
			});
			$('.ajax_cart_no_product').show();
		}
	}
};

function HoverWatcher(selector){
	this.hovering = false;
	var self = this;

	this.isHoveringOver = function() {
		return self.hovering;
	}

	$(selector).hover(function() {
		self.hovering = true;
	}, function() {
		self.hovering = false;
	})
}

//when document is loaded...
$(document).ready(function(){
	// expand/collapse management
	$('#block_cart_collapse').click(function(){
			ajaxCart.collapse();
	});
	$('#block_cart_expand').click(function(){
			ajaxCart.expand();
	});
	ajaxCart.overrideButtonsInThePage();

	var cart_qty = 0;
	var current_timestamp = parseInt(new Date().getTime() / 1000);

	if (typeof $('.ajax_cart_quantity').html() == 'undefined' || (typeof generated_date != 'undefined' && generated_date != null && (parseInt(generated_date) + 30) < current_timestamp))
		ajaxCart.refresh();
	else
		cart_qty = parseInt($('.ajax_cart_quantity').html());

	/* roll over cart */
	var cart_block = new HoverWatcher('#header #cart_block');
	var shopping_cart = new HoverWatcher('#shopping_cart');

		$("#shopping_cart").hover(
		function() {			
				$("#header #cart_block").stop(true, true).slideDown(450);
		},
		function() {			
			setTimeout(function() {
				if (!shopping_cart.isHoveringOver() && !cart_block.isHoveringOver())
					$("#header #cart_block").stop(true, true).slideUp(450);
			}, 200);
		}
	);

	$("#header #cart_block").hover(
		function() {
			$('#shopping_cart a').css('border-radius', '3px 3px 0px 0px');
		},
		function() {
			$('#shopping_cart a').css('border-radius', '3px');
			setTimeout(function() {
				if (!shopping_cart.isHoveringOver())
					$("#header #cart_block").stop(true, true).slideUp(450);
			}, 200);
		}
	);

	$('.delete_voucher').live('click', function() {
		$.ajax({
			type: 'POST',
			headers: { "cache-control": "no-cache" },
			async: true,
			cache: false,
			url:$(this).attr('href') + '?rand=' + new Date().getTime(),
			error: function(XMLHttpRequest, textStatus, errorThrown) {
				alert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
			}
		});
		$(this).parent().parent().remove();
		if ($('body').attr('id') == 'order' || $('body').attr('id') == 'order-opc')
		{
			if (typeof(updateAddressSelection) != 'undefined')
				updateAddressSelection();
			else
				location.reload();
		}
		return false;
	});

	$('#cart_navigation input').click(function(){
		$(this).attr('disabled', true).removeClass('exclusive').addClass('exclusive_disabled');
		$(this).closest("form").get(0).submit();
	});
});


if someone want to test, to understand here is website:  http://www.prylolle.se   just click "LÄGG I KUNDVAGNEN" on any product

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

I clicked on "LÄGG I KUNDVAGNEN" in Firefox, Chrome and IE (all browsers are the latest version)

I saw my product get added to cart.

I clicked on the checkout button and I saw the checkout process started with 1 product in the summary page. Didnt get any errors on my end.

 

Maybe try another PC.. or hit CTRL-F5 to refresh cache on the page and see if that fixes it..

 

*Also, you theme is using the presta 1.5 version cart system, so i dont think my patch will work on that since it relies on the new presta 1.6 ajax cart system. :)

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

I clicked on "LÄGG I KUNDVAGNEN" in Firefox, Chrome and IE (all browsers are the latest version)

I saw my product get added to cart.

I clicked on the checkout button and I saw the checkout process started with 1 product in the summary page. Didnt get any errors on my end.

 

Maybe try another PC.. or hit CTRL-F5 to refresh cache on the page and see if that fixes it..

hmm strange, I cleaned the browser cache and it does not work to me or to a friend in Chrome, in Internet explorer is working fine

My chrome version is 33.0.1750.154

Link to comment
Share on other sites

  • 4 weeks later...

Hey guys,

I think I found that issue with Empty Cart in Chrome.

Please check your SEO setting, make sure you don't have www in your URL.

with www, my site will add only...1 product. It doesn't add any more and Checkout show: Empty Cart.

 

When I remove www, it works great.

This issue only appear in Chrome

 

Bug reported here: http://forge.prestashop.com/browse/PSCSX-2013

Link to comment
Share on other sites

  • 3 months later...

This might fix the issue with touchscreen and the Cart: 

https://github.com/PrestaShop/PrestaShop/commit/f29395868025c2d5f20ab27f9521a1b480309f09

 

I think there is also a fix  for the hover problem on the Product grid (under Chrome / Windows 8) here: http://forge.prestashop.com/browse/PSCSX-1621

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

  • 2 months later...
  • 2 weeks later...

I have the problem - Add to cart works, but than when you open the cart its empty. Nothing help (clear smarty cache, disable it, force compilation, disable other cache). Only what helped was - clear cookies. This very strange, huh? Can't force customers to clear cookies.

Link to comment
Share on other sites

I have the problem - Add to cart works, but than when you open the cart its empty. Nothing help (clear smarty cache, disable it, force compilation, disable other cache). Only what helped was - clear cookies. This very strange, huh? Can't force customers to clear cookies.

 

this problem appears only if you - as a shop owner intensively deal with shop settings, and if you're logged to back office and front office at the same time. It's not normal, but unfortunately this happens sometimes.

 

are you able to test it as a customer, on clear browser where you arent logged as an admin ? just try to be like a real customer :-)

everything will be allright

 

i hope so :-)

Link to comment
Share on other sites

  • 1 month later...

Hi all 

 

I try to fix a bug what we have ...like others said but still when Im using Internet Explorer (vers. 10.0.20 )after add a product my cart is empty

 

 I try as a customer ( log out from admin panel in back office ect...) as an admin ect still same problem...

 

 

with Chrome, mozilla is OK

 

 

please try and give me  solution how to solve my problem ... 

 

http://mangoo.no

 

thx 4 any kind of help ...

 

 

Daniel

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

  • 1 month later...

Hi,

for me it looks like a cookie problem. I found that this problem is very hard to replicate, because sometimes it works, and sometimes not.

 

The deal is that, when you add a product to cart for the first time, a new cart is created and it's saved in database. But then presta tries to save cart_id to a cookie variable id_cart. It goes good for the first time, but when you refresh your page or go to another page (for example checkout) that cookie variable disappears.

 

Unfortunately I have no solution for this as for now.

Link to comment
Share on other sites

I have the same problem, and this is not only an administration problem, customers experiance this as well (although perhaps less often). Should not Prestashop have to fix this issue ? I am loosing sales all the time and it seems there is no way to fix this ?

 

 

Matthew

sinolec.co.uk

Link to comment
Share on other sites

Prestashop 1.6.0.11

Win 8.1

Touch screen

Chrome  40.0.2214.93 m

 

Cart link on top of the page (cart block) doesnt work when Ajax cart is enabled. No way to get into the cart.

Cart is working on Win8.1 touch screen when Ajax cart is disabled.

 

PrestaTeam - please fix it.

Link to comment
Share on other sites

  • 3 weeks later...

Hi. (Excuse my english)

 

After more than six hours checking all the modules...I found my solution for this problem PS 1.6.0.11 in all ibrowsers and different cities localization....

 

I put my store in maintenance mode

 

Download "GeoLiteCity.dat.gz" and decompress in ../tools/geoip (Maybe not neceesary this step)

 

In Preferences / Geolocaton (I think this is the real sollution)

 

Geolocation by other countries put in "All Functions Allowed" Save BOOM Cart working

 

Then i returne this option to "Visitors can view their catalog but can not place orders" Shopping Cart CONTINUE WORKING

 

Remember to Take out Maintenance mode

 

Try. I´m seek and tired

  • Like 1
Link to comment
Share on other sites

@JhOcKeR:

Your problem was other nature and not related to original issue posted here.

Issue posted here was presta bug and it is already fixed:

https://github.com/PrestaShop/PrestaShop/commit/f29395868025c2d5f20ab27f9521a1b480309f09

https://github.com/PrestaShop/PrestaShop/commit/c2364501c3592cc4e3ab6b131ecad9957f16a5c2

 

In your case it was local configuration problem :-), not presta bug.

Link to comment
Share on other sites

×
×
  • Create New...