PageSourceSearch

https://www.powerplustools.de/themes/powerplus/js/modules/blockcart/ajax-cart.js

js powerplustools.de collected 2026-09-25 20:42:46 UTC 40,794 bytes, 817 lines download raw bytes

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

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.