PageSourceSearch

http://apiario.eu/themes/butterfly/js/modules/blockcart/ajax-cart.js

js apiario.eu collected 2026-10-02 10:01:10 UTC 30,702 bytes, 861 lines download raw bytes

1/*
2* 2007-2014 PrestaShop
3*
4* NOTICE OF LICENSE
5*
6* This source file is subject to the Academic Free License (AFL 3.0)
7* that is bundled with this package in the file LICENSE.txt.
8* It is also available through the world-wide-web at this URL:
9* http://opensource.org/licenses/afl-3.0.php
10* If you did not receive a copy of the license and are unable to
11* obtain it through the world-wide-web, please send an email
12* to [email protected] so we can send you a copy immediately.
13*
14* DISCLAIMER
15*
16* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
17* versions in the future. If you wish to customize PrestaShop for your
18* needs please refer to http://www.prestashop.com for more information.
19*
20*  @author PrestaShop SA <[email protected]>
21*  @copyright  2007-2014 PrestaShop SA
22*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
23*  International Registered Trademark & Property of PrestaShop SA
24*/
25$(document).ready(function(){
26	ajaxCart.overrideButtonsInThePage();
27
28	$(document).on('click', '.block_cart_collapse', function(e){
29		e.preventDefault();
30		ajaxCart.collapse();
31	});
32	$(document).on('click', '.block_cart_expand', function(e){
33		e.preventDefault();
34		ajaxCart.expand();
35	});
36
37	var cart_qty = 0;
38	var current_timestamp = parseInt(new Date().getTime() / 1000);
39
40	if (typeof $('.ajax_cart_quantity').html() == 'undefined' || (typeof generated_date != 'undefined' && generated_date != null && (parseInt(generated_date) + 30) < current_timestamp))
41		ajaxCart.refresh();
42	else
43		cart_qty = parseInt($('.ajax_cart_quantity').html());
44
45	/* roll over cart */
46	var cart_block = new HoverWatcher('#header .cart_block');
47	var shopping_cart = new HoverWatcher('#header .shopping_cart');
48
49	if ('ontouchstart' in document.documentElement)
50	{
51		$('.shopping_cart > a:first').on('click', function(e){
52			e.preventDefault();
53		});
54	}
55
56	$(document).on('touchstart', '#header .shopping_cart a:first', function(){
57		if ($(this).next('.cart_block:visible').length)
58			$("#header .cart_block").stop(true, true).slideUp(450);
59		else
60			$("#header .cart_block").stop(true, true).slideDown(450);
61		e.preventDefault();
62		e.stopPropagation();
63	});
64
65	$("#header .shopping_cart a:first").hover(
66		function(){
67			if (ajaxCart.nb_total_products > 0 || cart_qty > 0)
68				$("#header .cart_block").stop(true, true).slideDown(450);
69		},
70		function(){
71			setTimeout(function(){
72				if (!shopping_cart.isHoveringOver() && !cart_block.isHoveringOver())
73					$("#header .cart_block").stop(true, true).slideUp(450);				
74			}, 200);
75		}
76	);
77
78	$("#header .cart_block").hover(
79		function(){
80		},
81		function(){
82			setTimeout(function(){
83				if (!shopping_cart.isHoveringOver())
84					$("#header .cart_block").stop(true, true).slideUp(450);
85			}, 200);
86		}
87	);
88
89	$(document).on('click', '.delete_voucher', function(e){
90		e.preventDefault();
91		$.ajax({
92			type: 'POST',
93			headers: { "cache-control": "no-cache" },
94			async: true,
95			cache: false,
96			url:$(this).attr('href') + '?rand=' + new Date().getTime()
97		});
98		$(this).parent().parent().remove();
99		if ($('body').attr('id') == 'order' || $('body').attr('id') == 'order-opc')
100		{
101			if (typeof(updateAddressSelection) != 'undefined')
102				updateAddressSelection();
103			else
104				location.reload();
105		}
106	});
107
108	$(document).on('click', '#cart_navigation input', function(e){
109		$(this).prop('disabled', 'disabled').addClass('disabled');
110		$(this).closest("form").get(0).submit();
111	});
112
113	$(document).on('click', '#layer_cart .cross, #layer_cart .continue, .layer_cart_overlay', function(e){
114		e.preventDefault();
115		$('.layer_cart_overlay').hide();
116		$('#layer_cart').fadeOut('fast');
117	});
118	
119	$('#columns #layer_cart, #columns .layer_cart_overlay').detach().prependTo('#columns');
120});
121
122//JS Object : update the cart by ajax actions
123var ajaxCart = {
124	nb_total_products: 0,
125	//override every button in the page in relation to the cart
126	overrideButtonsInThePage : function(){
127		//for every 'add' buttons...
128		$(document).on('click', '.ajax_add_to_cart_button', function(e){
129			e.preventDefault();
130			
131			
132			var idProduct =  $(this).data('id-product');
133			if ($(this).prop('disabled') != 'disabled')
134				ajaxCart.add(idProduct, null, false, this);
135		});
136		//for product page 'add' button...
137		$(document).on('click', '#add_to_cart button', function(e){
138			e.preventDefault();
139			ajaxCart.add($('#product_page_product_id').val(), $('#idCombination').val(), true, null, $('#quantity_wanted').val(), null);
140		});
141
142		//for 'delete' buttons in the cart block...
143		$(document).on('click', '.cart_block_list .ajax_cart_block_remove_link', function(e){
144			e.preventDefault();
145			// Customized product management
146			var customizationId = 0;
147			var productId = 0;
148			var productAttributeId = 0;
149			var customizableProductDiv = $($(this).parent().parent()).find("div[data-id^=deleteCustomizableProduct_]");
150			var idAddressDelivery = false;
151
152			if (customizableProductDiv && $(customizableProductDiv).length)
153			{
154				var ids = customizableProductDiv.data('id').split('_');
155				if (typeof(ids[1]) != 'undefined')
156				{
157					customizationId = parseInt(ids[1]);
158					productId = parseInt(ids[2]);
159					if (typeof(ids[3]) != 'undefined')
160						productAttributeId = parseInt(ids[3]);
161					if (typeof(ids[4]) != 'undefined')
162						idAddressDelivery = parseInt(ids[4]);
163				}
164			}
165
166			// Common product management
167			if (!customizationId)
168			{
169				//retrieve idProduct and idCombination from the displayed product in the block cart
170				var firstCut = $(this).parent().parent().data('id').replace('cart_block_product_', '');
171				firstCut = firstCut.replace('deleteCustomizableProduct_', '');
172				ids = firstCut.split('_');
173				productId = parseInt(ids[0]);
174
175				if (typeof(ids[1]) != 'undefined')
176					productAttributeId = parseInt(ids[1]);
177				if (typeof(ids[2]) != 'undefined')
178					idAddressDelivery = parseInt(ids[2]);
179			}
180
181			// Removing product from the cart
182			ajaxCart.remove(productId, productAttributeId, customizationId, idAddressDelivery);
183		});
184	},
185
186	// try to expand the cart
187	expand : function(){
188		if ($('.cart_block_list').hasClass('collapsed'))
189		{
190			$('.cart_block_list.collapsed').slideDown({
191				duration: 450,
192				complete: function(){
193					$(this).addClass('expanded').removeClass('collapsed');
194				}
195			});
196
197			// save the expand statut in the user cookie
198			$.ajax({
199				type: 'POST',
200				headers: { "cache-control": "no-cache" },
201				url: baseDir + 'modules/blockcart/blockcart-set-collapse.php' + '?rand=' + new Date().getTime(),
202				async: true,
203				cache: false,
204				data: 'ajax_blockcart_display=expand',
205				complete: function(){
206					$('.block_cart_expand').fadeOut('fast', function(){
207						$('.block_cart_collapse').fadeIn('fast');
208					});
209				}			
210			});
211		}
212	},
213
214	// try to collapse the cart
215	collapse : function(){
216		if ($('.cart_block_list').hasClass('expanded'))
217		{
218			$('.cart_block_list.expanded').slideUp('slow', function(){
219				$(this).addClass('collapsed').removeClass('expanded');
220			});
221
222			// save the expand statut in the user cookie
223			$.ajax({
224				type: 'POST',
225				headers: { "cache-control": "no-cache" },
226				url: baseDir + 'modules/blockcart/blockcart-set-collapse.php' + '?rand=' + new Date().getTime(),
227				async: true,
228				cache: false,
229				data: 'ajax_blockcart_display=collapse' + '&rand=' + new Date().getTime(),
230				complete: function(){
231					$('.block_cart_collapse').fadeOut('fast', function(){
232						$('.block_cart_expand').fadeIn('fast');
233					});
234				}
235			});
236		}
237	},
238	// Fix display when using back and previous browsers buttons
239	refresh : function(){
240		$.ajax({
241			type: 'POST',
242			headers: { "cache-control": "no-cache" },
243			url: baseUri + '?rand=' + new Date().getTime(),
244			async: true,
245			cache: false,
246			dataType : "json",
247			data: 'controller=cart&ajax=true&token=' + static_token,
248			success: function(jsonData)
249			{
250				ajaxCart.updateCart(jsonData);
251			}
252		});
253	},
254
255	// Update the cart information
256	updateCartInformation : function (jsonData, addedFromProductPage){
257		ajaxCart.updateCart(jsonData);
258		//reactive the button when adding has finished
259		if (addedFromProductPage) 
260		{
261			$('#add_to_cart button').removeProp('disabled').removeClass('disabled');
262			if (!jsonData.hasError || jsonData.hasError == false)
263				$('#add_to_cart button').addClass('added');
264			else
265				$('#add_to_cart button').removeClass('added');
266		}
267		else
268			$('.ajax_add_to_cart_button').removeProp('disabled');
269	},
270	// close fancybox
271	updateFancyBox : function (){},
272	// add a product in the cart via ajax
273	add : function(idProduct, idCombination, addedFromProductPage, callerElement, quantity, whishlist){
274		if (addedFromProductPage && !checkCustomizations())
275		{
276			if (!!$.prototype.fancybox)
277			    $.fancybox.open([
278			        {
279			            type: 'inline',
280			            autoScale: true,
281			            minHeight: 30,
282			            content: '<p class="fancybox-error">' + fieldRequired + '</p>'
283			        }
284			    ], {
285			        padding: 0
286			    });
287			else
288			    alert(fieldRequired);
289            return;
290		}
291		emptyCustomizations();
292		//disabled the button when adding to not double add if user double click
293		if (addedFromProductPage)
294		{
295			$('#add_to_cart button').prop('disabled', 'disabled').addClass('disabled');
296			$('.filled').removeClass('filled');
297		}
298		else
299			$(callerElement).prop('disabled', 'disabled');
300
301		if ($('.cart_block_list').hasClass('collapsed'))
302			this.expand();
303		//send the ajax request to the server
304		$.ajax({
305			type: 'POST',
306			headers: { "cache-control": "no-cache" },
307			url: baseUri + '?rand=' + new Date().getTime(),
308			async: true,
309			cache: false,
310			dataType : "json",
311			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): ''),
312			success: function(jsonData,textStatus,jqXHR)
313			{
314				// add appliance to whishlist module
315				if (whishlist && !jsonData.errors)
316					WishlistAddProductCart(whishlist[0], idProduct, idCombination, whishlist[1]);
317				
318				if (!jsonData.hasError)
319				{
320					if (contentOnly)
321						window.parent.ajaxCart.updateCartInformation(jsonData, addedFromProductPage);
322					else
323						ajaxCart.updateCartInformation(jsonData, addedFromProductPage);
324
325					if (jsonData.crossSelling)
326						$('.crossseling').html(jsonData.crossSelling);
327
328					if (idCombination)
329						$(jsonData.products).each(function(){
330							if (this.id != undefined && this.id == parseInt(idProduct) && this.idCombination == parseInt(idCombination))
331								if (contentOnly)
332									window.parent.ajaxCart.updateLayer(this);	
333								else
334									ajaxCart.updateLayer(this);
335						});
336					else
337						$(jsonData.products).each(function(){
338							if (this.id != undefined && this.id == parseInt(idProduct))
339								if (contentOnly)
340									window.parent.ajaxCart.updateLayer(this);
341								else
342									ajaxCart.updateLayer(this);					
343						});
344					if (contentOnly)
345						parent.$.fancybox.close();
346				}
347				else 
348				{
349					if (contentOnly)
350						window.parent.ajaxCart.updateCart(jsonData);
351					else
352						ajaxCart.updateCart(jsonData);	
353					if (addedFromProductPage)
354						$('#add_to_cart button').removeProp('disabled').removeClass('disabled');
355					else
356						$(callerElement).removeProp('disabled');
357				}
358
359			},
360			error: function(XMLHttpRequest, textStatus, errorThrown)
361			{
362				var error = "Impossible to add the product to the cart.<br/>textStatus: '" + textStatus + "'<br/>errorThrown: '" + errorThrown + "'<br/>responseText:<br/>" + XMLHttpRequest.responseText;
363				if (!!$.prototype.fancybox)
364				    $.fancybox.open([
365				    {
366				        type: 'inline',
367				        autoScale: true,
368				        minHeight: 30,
369				        content: '<p class="fancybox-error">' + error + '</p>'
370				    }],
371					{
372				        padding: 0
373				    });
374				else
375				    alert(error);
376				//reactive the button when adding has finished
377				if (addedFromProductPage)
378					$('#add_to_cart button').removeProp('disabled').removeClass('disabled');
379				else
380					$(callerElement).removeProp('disabled');
381			}
382		});
383	},
384
385	//remove a product from the cart via ajax
386	remove : function(idProduct, idCombination, customizationId, idAddressDelivery){
387		//send the ajax request to the server
388		$.ajax({
389			type: 'POST',
390			headers: { "cache-control": "no-cache" },
391			url: baseUri + '?rand=' + new Date().getTime(),
392			async: true,
393			cache: false,
394			dataType : "json",
395			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',
396			success: function(jsonData)	{
397				ajaxCart.updateCart(jsonData);
398				if ($('body').attr('id') == 'order' || $('body').attr('id') == 'order-opc')
399					deleteProductFromSummary(idProduct+'_'+idCombination+'_'+customizationId+'_'+idAddressDelivery);
400			},
401			error: function()
402            {
403				var error = 'ERROR: unable to delete the product';
404				if (!!$.prototype.fancybox)
405				{
406				    $.fancybox.open([
407				        {
408				            type: 'inline',
409				            autoScale: true,
410				            minHeight: 30,
411				            content: error
412				        }
413				    ], {
414				        padding: 0
415				    });
416				}
417				else
418				    alert(error);
419            }
420		});
421	},
422
423	//hide the products displayed in the page but no more in the json data
424	hideOldProducts : function(jsonData){
425		//delete an eventually removed product of the displayed cart (only if cart is not empty!)
426		if ($('.cart_block_list:first dl.products').length > 0)
427		{
428			var removedProductId = null;
429			var removedProductData = null;
430			var removedProductDomId = null;
431			//look for a product to delete...
432			$('.cart_block_list:first dl.products dt').each(function(){
433				//retrieve idProduct and idCombination from the displayed product in the block cart
434				var domIdProduct = $(this).data('id');
435				var firstCut = domIdProduct.replace('cart_block_product_', '');
436				var ids = firstCut.split('_');
437
438				//try to know if the current product is still in the new list
439				var stayInTheCart = false;
440				for (aProduct in jsonData.products)
441				{
442					//we've called the variable aProduct because IE6 bug if this variable is called product
443					//if product has attributes
444					if (jsonData.products[aProduct]['id'] == ids[0] && (!ids[1] || jsonData.products[aProduct]['idCombination'] == ids[1]))
445					{
446						stayInTheCart = true;
447						// update the product customization display (when the product is still in the cart)
448						ajaxCart.hideOldProductCustomizations(jsonData.products[aProduct], domIdProduct);
449					}
450				}
451				//remove product if it's no more in the cart
452				if (!stayInTheCart)
453				{
454					removedProductId = $(this).data('id');
455					if (removedProductId != null)
456					{
457						var firstCut =  removedProductId.replace('cart_block_product_', '');
458						var ids = firstCut.split('_');
459
460						$('dt[data-id="' + removedProductId + '"]').addClass('strike').fadeTo('slow', 0, function(){
461							$(this).slideUp('slow', function(){
462								$(this).remove();
463								// If the cart is now empty, show the 'no product in the cart' message and close detail
464								if($('.cart_block:first dl.products dt').length == 0)
465								{
466									$("#header .cart_block").stop(true, true).slideUp(200);
467									$('.cart_block_no_products:hidden').slideDown(450);
468									$('.cart_block dl.products').remove();
469								}
470							});
471						});
472						$('dd[data-id="cart_block_combination_of_' + ids[0] + (ids[1] ? '_'+ids[1] : '') + (ids[2] ? '_'+ids[2] : '') + '"]').fadeTo('fast', 0, function(){
473							$(this).slideUp('fast', function(){
474								$(this).remove();
475							});
476						});
477					}
478
479				}
480			});
481		}
482	},
483
484	hideOldProductCustomizations : function (product, domIdProduct){
485		var customizationList = $('ul[data-id="customization_' + product['id'] + '_' + product['idCombination'] + '"]');
486		if(customizationList.length > 0)
487		{
488			$(customizationList).find("li").each(function(){
489				$(this).find("div").each(function(){
490					var customizationDiv = $(this).data('id');
491					var tmp = customizationDiv.replace('deleteCustomizableProduct_', '');
492					var ids = tmp.split('_');
493					if ((parseInt(product.idCombination) == parseInt(ids[2])) && !ajaxCart.doesCustomizationStillExist(product, ids[0]))
494						$('div[data-id="' + customizationDiv + '"]').parent().addClass('strike').fadeTo('slow', 0, function(){
495							$(this).slideUp('slow');
496							$(this).remove();
497						});
498				});
499			});
500		}
501
502		var removeLinks = $('.deleteCustomizableProduct[data-id="' + domIdProduct + '"]').find('.ajax_cart_block_remove_link');
503		if (!product.hasCustomizedDatas && !removeLinks.length)
504			$('div[data-id="' + domIdProduct + '"]' + ' span.remove_link').html('<a class="ajax_cart_block_remove_link" rel="nofollow" href="' + baseUri + '?controller=cart&amp;delete=1&amp;id_product=' + product['id'] + '&amp;ipa=' + product['idCombination'] + '&amp;
504token=' + static_token + '"> </a>');
505		if (product.is_gift)
506			$('div[data-id="' + domIdProduct + '"]' + ' span.remove_link').html('');
507	},
508
509	doesCustomizationStillExist : function (product, customizationId){
510		var exists = false;
511
512		$(product.customizedDatas).each(function(){
513			if (this.customizationId == customizationId)
514			{
515				exists = true;
516				// This return does not mean that we found nothing but simply break the loop
517				return false;
518			}
519		});
520		return (exists);
521	},
522
523	//refresh display of vouchers (needed for vouchers in % of the total)
524	refreshVouchers : function (jsonData){
525		if (typeof(jsonData.discounts) == 'undefined' || jsonData.discounts.length == 0)
526			$('.vouchers').hide();
527		else
528		{
529			$('.vouchers tbody').html('');
530
531			for (i=0;i<jsonData.discounts.length;i++)
532			{
533				if (parseFloat(jsonData.discounts[i].price_float) > 0)
534				{
535					var delete_link = '';
536					if (jsonData.discounts[i].code.length)
537						delete_link = '<a class="delete_voucher" href="'+jsonData.discounts[i].link+'" title="'+delete_txt+'"><i class="icon-remove-sign"></i></a>';
538					$('.vouchers tbody').append($(
539						'<tr class="bloc_cart_voucher" data-id="bloc_cart_voucher_'+jsonData.discounts[i].id+'">'
540						+'	<td class="quantity">1x</td>'
541						+'	<td class="name" title="'+jsonData.discounts[i].description+'">'+jsonData.discounts[i].name+'</td>'
542						+'	<td class="price">-'+jsonData.discounts[i].price+'</td>'
543						+'	<td class="delete">' + delete_link + '</td>'
544						+'</tr>'
545					));
546				}
547			}
548			$('.vouchers').show();
549		}
550
551	},
552
553	// Update product quantity
554	updateProductQuantity : function (product, quantity){
555		$('dt[data-id=cart_block_product_' + product.id + '_' + (product.idCombination ? product.idCombination : '0')+ '_' + (product.idAddressDelivery ? product.idAddressDelivery : '0') + '] .quantity').fadeTo('fast', 0, function(){
556			$(this).text(quantity);
557			$(this).fadeTo('fast', 1, function(){
558				$(this).fadeTo('fast', 0, function(){
559					$(this).fadeTo('fast', 1, function(){
560						$(this).fadeTo('fast', 0, function(){
561							$(this).fadeTo('fast', 1);
562						});
563					});
564				});
565			});
566		});
567	},
568
569	//display the products witch are in json data but not already displayed
570	displayNewProducts : function(jsonData){
571		//add every new products or update displaying of every updated products
572		$(jsonData.products).each(function(){
573			//fix ie6 bug (one more item 'undefined' in IE6)
574			if (this.id != undefined)
575			{
576				//create a container for listing the products and hide the 'no product in the cart' message (only if the cart was empty)
577
578				if ($('.cart_block:first dl.products').length == 0)
579				{
580					$('.cart_block_no_products').before('<dl class="products"></dl>');
581					$('.cart_block_no_products').hide();
582				}
583				//if product is not in the displayed cart, add a new product's line
584				var domIdProduct = this.id + '_' + (this.idCombination ? this.idCombination : '0') + '_' + (this.idAddressDelivery ? this.idAddressDelivery : '0');
585				var domIdProductAttribute = this.id + '_' + (this.idCombination ? this.idCombination : '0');
586
587				if ($('dt[data-id="cart_block_product_' + domIdProduct + '"]').length == 0)
588				{
589					var productId = parseInt(this.id);
590					var productAttributeId = (this.hasAttributes ? parseInt(this.attributes) : 0);
591					var content =  '<dt class="unvisible" data-id="cart_block_product_' + domIdProduct + '">';
592					var name = $.trim($('<span />').html(this.name).text());
593					name = (name.length > 12 ? name.substring(0, 10) + '...' : name);
594					content += '<a class="cart-images" href="' + this.link + '" title="' + name + '"><img  src="' + this.image_cart + '" alt="' + this.name +'"></a>';
595					content += '<div class="cart-info"><div class="product-name">' + '<span class="quantity-formated"><span class="quantity">' + this.quantity + '</span>&nbsp;x&nbsp;</span><a href="' + this.link + '" title="' + this.name + '" class="cart_block_product_name">' + name + '</a></div>';
596					if (this.hasAttributes)
597						  content += '<div class="product-atributes"><a href="' + this.link + '" title="' + this.name + '">' + this.attributes + '</a></div>';
598					if (typeof(freeProductTranslation) != 'undefined')
599						content += '<span class="price">' + (parseFloat(this.price_float) > 0 ? this.priceByLine : freeProductTranslation) + '</span></div>';
600
601					if (typeof(this.is_gift) == 'undefined' || this.is_gift == 0)
602						content += '<span class="remove_link"><a rel="nofollow" class="ajax_cart_block_remove_link" href="' + baseUri + '?controller=cart&amp;delete=1&amp;id_product=' + productId + '&amp;
602token=' + static_token + (this.hasAttributes ? '&amp;ipa=' + parseInt(this.idCombination) : '') + '"> </a></span>';
603					else
604						content += '<span class="remove_link"></span>';
605					content += '</dt>';
606					if (this.hasAttributes)
607						content += '<dd data-id="cart_block_combination_of_' + domIdProduct + '" class="unvisible">';
608					if (this.hasCustomizedDatas)
609						content += ajaxCart.displayNewCustomizedDatas(this);
610					if (this.hasAttributes) content += '</dd>';
611
612					$('.cart_block dl.products').append(content);
613				}
614				//else update the product's line
615				else
616				{
617					var jsonProduct = this;
618					if($.trim($('dt[data-id="cart_block_product_' + domIdProduct + '"] .quantity').html()) != jsonProduct.quantity || $.trim($('dt[data-id="cart_block_product_' + domIdProduct + '"] .price').html()) != jsonProduct.priceByLine)
619					{
620						// Usual product
621						if (!this.is_gift)
622							$('dt[data-id="cart_block_product_' + domIdProduct + '"] .price').text(jsonProduct.priceByLine);
623						else
624							$('dt[data-id="cart_block_product_' + domIdProduct + '"] .price').html(freeProductTranslation);
625						ajaxCart.updateProductQuantity(jsonProduct, jsonProduct.quantity);
626
627						// Customized product
628						if (jsonProduct.hasCustomizedDatas)
629						{
630							customizationFormatedDatas = ajaxCart.displayNewCustomizedDatas(jsonProduct);
631							if (!$('ul[data-id="customization_' + domIdProductAttribute + '"]').length)
632							{
633								if (jsonProduct.hasAttributes)
634									$('dd[data-id="cart_block_combination_of_' + domIdProduct + '"]').append(customizationFormatedDatas);
635								else
636									$('.cart_block dl.products').append(customizationFormatedDatas);
637							}
638							else
639							{
640								$('ul[data-id="customization_' + domIdProductAttribute + '"]').html('');
641								$('ul[data-id="customization_' + domIdProductAttribute + '"]').append(customizationFormatedDatas);
642							}
643						}
644					}
645				}
646				$('.cart_block dl.products .unvisible').slideDown(450).removeClass('unvisible');
647
648			var removeLinks = $('dt[data-id="cart_block_product_' + domIdProduct + '"]').find('a.ajax_cart_block_remove_link');
649			if (this.hasCustomizedDatas && removeLinks.length)
650				$(removeLinks).each(function(){
651					$(this).remove();
652				});
653			}
654		});
655	},
656
657	displayNewCustomizedDatas : function(product){
658		var content = '';
659		var productId = parseInt(product.id);
660		var productAttributeId = typeof(product.idCombination) == 'undefined' ? 0 : parseInt(product.idCombination);
661		var hasAlreadyCustomizations = $('ul[data-id="customization_' + productId + '_' + productAttributeId + '"]').length;
662
663		if (!hasAlreadyCustomizations)
664		{
665			if (!product.hasAttributes)
666				content += '<dd data-id="cart_block_combination_of_' + productId + '" class="unvisible">';
667			if ($('ul[data-id="customization_' + productId + '_' + productAttributeId + '"]').val() == undefined)
668				content += '<ul class="cart_block_customizations" data-id="customization_' + productId + '_' + productAttributeId + '">';
669		}
670
671		$(product.customizedDatas).each(function(){
672			var done = 0;
673			customizationId = parseInt(this.customizationId);
674			productAttributeId = typeof(product.idCombination) == 'undefined' ? 0 : parseInt(product.idCombination);
675			content += '<li name="customization"><div class="deleteCustomizableProduct" data-id="deleteCustomizableProduct_' + customizationId + '_' + productId + '_' + (productAttributeId ?  productAttributeId : '0') + '"><a rel="nofollow" class="ajax_cart_block_remove_link" href="' + baseUri + '?controller=cart&amp;delete=1&amp;id_product=' + productId + '&amp;ipa=' + productAttributeId + '&amp;id_customization=' + customizationId + '&amp;
675token=' + static_token + '"></a></div>';
676
677			// Give to the customized product the first textfield value as name
678			$(this.datas).each(function(){
679				if (this['type'] == CUSTOMIZE_TEXTFIELD)
680				{
681					$(this.datas).each(function(){
682						if (this['index'] == 0)
683						{
684							content += ' ' + this.truncatedValue.replace(/<br \/>/g, ' ');
685							done = 1;
686							return false;
687						}
688					})
689				}
690			});
691
692			// If the customized product did not have any textfield, it will have the customizationId as name
693			if (!done)
694				content += customizationIdMessage + customizationId;
695			if (!hasAlreadyCustomizations) content += '</li>';
696			// Field cleaning
697			if (customizationId)
698			{
699				$('#uploadable_files li div.customizationUploadBrowse img').remove();
700				$('#text_fields input').attr('value', '');
701			}
702		});
703
704		if (!hasAlreadyCustomizations)
705		{
706			content += '</ul>';
707			if (!product.hasAttributes) content += '</dd>';
708		}
709		return (content);
710	},
711
712	updateLayer : function(product){
713		$('#layer_cart_product_title').text(product.name);
714		$('#layer_cart_product_attributes').text('');
715		if (product.hasAttributes && product.hasAttributes == true)
716			$('#layer_cart_product_attributes').html(product.attributes);
717		$('#layer_cart_product_price').text(product.price);
718		$('#layer_cart_product_quantity').text(product.quantity);
719		$('.layer_cart_img').html('<img class="layer_cart_img img-responsive" src="' + product.image + '" alt="' + product.name + '" title="' + product.name + '" />');
720
721		var n = parseInt($(window).scrollTop()) + 100 + 'px';
722
723		$('.layer_cart_overlay').css('width','100%');
724		$('.layer_cart_overlay').css('height','100%');
725		$('.layer_cart_overlay').show();
726		$('#layer_cart').css({'top': n}).fadeIn('fast');
727		crossselling_serialScroll();
728	},
729
730	//genarally update the display of the cart
731	updateCart : function(jsonData){
732		//user errors display
733		if (jsonData.hasError)
734		{
735			var errors = '';
736			for (error in jsonData.errors)
737				//IE6 bug fix
738				if (error != 'indexOf')
739					errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
740			if (!!$.prototype.fancybox)
741			    $.fancybox.open([
742			        {
743			            type: 'inline',
744			            autoScale: true,
745			            minHeight: 30,
746			            content: '<p class="fancybox-error">' + errors + '</p>'
747			        }
748			    ], {
749			        padding: 0
750			    });
751			else
752			    alert(errors);
753		}
754		else
755		{
756			ajaxCart.updateCartEverywhere(jsonData);
757			ajaxCart.hideOldProducts(jsonData);
758			ajaxCart.displayNewProducts(jsonData);
759			ajaxCart.refreshVouchers(jsonData);
760
761			//update 'first' and 'last' item classes
762			$('.cart_block .products dt').removeClass('first_item').removeClass('last_item').removeClass('item');
763			$('.cart_block .products dt:first').addClass('first_item');
764			$('.cart_block .products dt:not(:first,:last)').addClass('item');
765			$('.cart_block .products dt:last').addClass('last_item');
766		}
767	},
768
769	//update general cart informations everywhere in the page
770	updateCartEverywhere : function(jsonData){
771		$('.ajax_cart_total').text($.trim(jsonData.productTotal));
772
773		if (parseFloat(jsonData.shippingCostFloat) > 0)
774			$('.ajax_cart_shipping_cost').text(jsonData.shippingCost);
775		else if (typeof(freeShippingTranslation) != 'undefined')
776				$('.ajax_cart_shipping_cost').html(freeShippingTranslation);
777
778		$('.ajax_cart_tax_cost').text(jsonData.taxCost);
779		$('.cart_block_wrapping_cost').text(jsonData.wrappingCost);
780		$('.ajax_block_cart_total').text(jsonData.total);
781		$('.ajax_block_products_total').text(jsonData.productTotal);
782        $('.ajax_total_price_wt').text(jsonData.total_price_wt);
783
784		if (parseFloat(jsonData.freeShippingFloat) > 0)
785		{
786			$('.ajax_cart_free_shipping').html(jsonData.freeShipping);
787			$('.freeshipping').fadeIn(0);
788		}
789		else if (parseFloat(jsonData.freeShippingFloat) == 0)
790			$('.freeshipping').fadeOut(0);
791
792		this.nb_total_products = jsonData.nbTotalProducts;
793
794		if (parseInt(jsonData.nbTotalProducts) > 0)
795		{
796			$('.ajax_cart_no_product').hide();
797			$('.ajax_cart_quantity').text(jsonData.nbTotalProducts);
798			$('.ajax_cart_quantity').fadeIn('slow');
799			$('.ajax_cart_total').fadeIn('slow');
800
801			if (parseInt(jsonData.nbTotalProducts) > 1)
802			{
803				$('.ajax_cart_product_txt').each( function (){
804					$(this).hide();
805				});
806
807				$('.ajax_cart_product_txt_s').each( function (){
808					$(this).show();
809				});
810			}
811			else
812			{
813				$('.ajax_cart_product_txt').each( function (){
814					$(this).show();
815				});
816
817				$('.ajax_cart_product_txt_s').each( function (){
818					$(this).hide();
819				});
820			}
821		}
822		else
823		{
824			$('.ajax_cart_quantity, .ajax_cart_product_txt_s, .ajax_cart_product_txt, .ajax_cart_total').each(function(){
825				$(this).hide();
826			});
827			$('.ajax_cart_no_product').show('slow');
828		}
829	}
830};
831
832function HoverWatcher(selector)
833{
834	this.hovering = false;
835	var self = this;
836
837	this.isHoveringOver = function(){
838		return self.hovering;
839	}
840
841	$(selector).hover(function(){
842		self.hovering = true;
843	}, function(){
844		self.hovering = false;
845	})
846}
847
848function crossselling_serialScroll()
849{
850	if (!!$.prototype.bxSlider)
851		$('#blockcart_caroucel').bxSlider({
852			minSlides: 2,
853			maxSlides: 4,
854			slideWidth: 178,
855			slideMargin: 20,
856			moveSlides: 1,
857			infiniteLoop: false,
858	  		hideControlOnEnd: true,
859			pager: false
860		});
861}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.