在prestashop上添加产品时,ajax购物车出错

问题描述 投票:1回答:1

嘿,我上周以来有一个prestashop 1.6.0.11和ajax购物车的问题

当我点击“添加到购物车”按钮时,页面上和页眉中的购物车上没有任何操作。 (如果我刷新页面,产品都在购物车中)。

我的控制台中出现此错误:

ajax-cart.js:329 =>未捕获的TypeError:无法读取属性'hasError'为null

发送ajax请求,但结果为“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

编辑:

这是来自ajax-cart.js的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 ?
            {
             // ...

在PHP中,Prestashop工作和这个之间没有区别。

编辑2:

我发现程序停在CartController.php中的displayAjax()中:

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

什么是'总结'?

有人有解决方案吗?

php jquery ajax prestashop prestashop-1.6
1个回答
0
投票

这是决心。

问题来自Smarty插件,它在一些TPL的开头添加了一些char。

所以,Json Encode返回错误。

© www.soinside.com 2019 - 2024. All rights reserved.