如何刷新页面并删除删除产品,当单击 opencart header 下拉购物车中的删除按钮时

How to refresh the page and remove delete product, when click on delete button in dropdown cart on header in opencart

在 opencart 中 header 上点击下拉购物车上的删除按钮时,我尝试刷新页面并删除购物车删除数据。我在 cart.tpl 上找到了位置,但单击该按钮时找不到功能的位置,即

onclick="cart.remove('<?php echo $product['key']; ?>');

我尝试使用 jquery

刷新页面
    <script type="text/javascript">
  jQuery(document).ready(function(){
    $('.dropdown-menu .text-center .btn-xs').click(function(){
      location.reload(); 
    });

  });  
</script>

刷新页面但不删除购物车产品。

打开文件 catalog/view/javascript/common.js。转到 line 200

改变这个

'remove': function(key) {
        $.ajax({
            url: 'index.php?route=checkout/cart/remove',
            type: 'post',
            data: 'key=' + key,
            dataType: 'json',
            beforeSend: function() {
                $('#cart > button').button('loading');
            },
            complete: function() {
                $('#cart > button').button('reset');
            },          
            success: function(json) {
                // Need to set timeout otherwise it wont update the total
                setTimeout(function () {
                    $('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
                }, 100);

                if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
                    location = 'index.php?route=checkout/cart';
                } else {
                    $('#cart > ul').load('index.php?route=common/cart/info ul li');
                }
            }

至此

'remove': function(key) {
        $.ajax({
            url: 'index.php?route=checkout/cart/remove',
            type: 'post',
            data: 'key=' + key,
            dataType: 'json',
            beforeSend: function() {
                $('#cart > button').button('loading');
            },
            complete: function() {
                $('#cart > button').button('reset');
            },          
            success: function(json) {
                // Need to set timeout otherwise it wont update the total
                setTimeout(function () {
                    $('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
                }, 100);

                if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
                    location = 'index.php?route=checkout/cart';
                } else {
                    $('#cart > ul').load('index.php?route=common/cart/info ul li');
                }
                location.reload();
            }