簡體   English   中英

在prestashop上添加產品時,ajax購物車出現錯誤

[英]Error with ajax cart when add product on prestashop

嘿,自上周以來,我遇到了一個prestashop 1.6.0.11和ajax購物車的問題

當我單擊“添加到購物車”按鈕時,頁面上和標題中的購物車上沒有任何操作。 (如果我刷新頁面,則產品在購物車中)。

我的控制台中出現此錯誤:

ajax-cart.js:329 =>未捕獲的TypeError:無法讀取null的屬性“ hasError”

發送了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 
{

什么是“摘要”?

有人有解決辦法嗎?

解決了

問題來自Smarty插件,該插件在某些TPL的開頭添加了一些字符。

因此,Json Encode返回錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM