简体   繁体   中英

Error with ajax cart when add product on prestashop

Hey I have a problem since last week with a prestashop 1.6.0.11 and ajax cart

When I click on "add to cart" button there are no action on page and on the cart in the header. (if I refresh the page, products are in the cart).

I have this error in my console :

ajax-cart.js:329 => Uncaught TypeError: Cannot read property 'hasError' of null

The ajax request is send, but the result is "null" :

https://www.prestashop.com/forums/uploads/monthly_10_2015/post-833314-0-21064100-1444814390.png

https://www.prestashop.com/forums/uploads/monthly_10_2015/post-833314-0-07732700-1444814388.png

EDIT :

Here is the js code from ajax-cart.js :

    $.ajax({
        type: 'POST',
        headers: { "cache-control": "no-cache" },
        url: baseUri + '?rand=' + new Date().getTime(),
        async: true,
        cache: false,
        dataType : "json",
        data: 'controller=cart&add=1&ajax=true&qty=' + ((quantity && quantity != null) ? quantity : '1') + '&id_product=' + idProduct + '&token=' + static_token + ( (parseInt(idCombination) && idCombination != null) ? '&ipa=' + parseInt(idCombination): ''),
        success: function(jsonData,textStatus,jqXHR)
        {
            // add appliance to whishlist module
            if (whishlist && !jsonData.errors)
                WishlistAddProductCart(whishlist[0], idProduct, idCombination, whishlist[1]);

    /* line 329 => */   if (!jsonData.hasError) // <-- jsonData object is NULL , why ?
            {
             // ...

In the PHP there's no difference between a Prestashop which working and this one.

EDIT 2 :

I found where the program stop in displayAjax() in CartController.php :

if (Tools::getIsset('summary')) // == false 
{

What is 'summary' ?

Someone have a solution ?

It's resolve.

The problem came from a Smarty Plugin which add some char at the start of some TPL.

So, Json Encode return error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM