prestashop 中未显示函数 ajax-cart.js 的更改

Changes to the function ajax-cart.js not showing in prestashop

我对函数做了一些修改themes/default-bootstrap/js/modules/blockcart/ajax-cart.js.

    $(document).off('click', '#add_to_cart button').on('click', '#add_to_cart button', function(e){
        e.preventDefault();
        console.log('product-id:'+$('#product_page_product_id').val()); //added this line
        console.log('quantity-wanted:'+$('#quantity_wanted').val()); //and this line
        ajaxCart.add($('#product_page_product_id').val(), $('#idCombination').val(), true, null, $('#quantity_wanted').val(), null);
    });

但是当我将它上传到服务器并在浏览器中检查脚本时,我仍然看到旧脚本。 我刷新了 ftp,清除了 prestashop 缓存和浏览器缓存。 为什么浏览器没有显示更新后的功能?

尝试删除文件夹 "cache/smarty" 和文件 "cache/class_index.php" 以防万一。

你说你清除了缓存,但没有说明具体是如何清除的。删除这些文件肯定会清除缓存,如果文件在服务器中但未被 Prestashop 使用,则可能是缓存问题。

此外,该脚本也在主题文件夹之外的另一个地方:

./modules/blockcart/ajax-cart.js

也尝试更改那里的脚本。

如果它仍然不起作用,请检查您是否没有安装替换核心 blockcart 模块的外部模块。如果您使用以下命令搜索该 js 文件的所有实例的位置(假设您对服务器具有命令行访问权限),可能会有所帮助:

须藤查找。 -姓名"ajax-cart.js"

了解使用以下命令调用 java 文件的位置可能也有帮助:

sudo grep -r --include=*.php "ajax-cart.js"

我遇到过类似的问题,我按照说明解决了。希望对你有帮助。

清除浏览器缓存 (ctl + f5)