PageSourceSearch

https://www.swiiim.fr/themes/theme1242/js/modules/blockcart/ajax-cart.js

js swiiim.fr collected 2026-09-24 13:10:44 UTC 31,038 bytes, 862 lines download raw bytes

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

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.