繁体   English   中英

如何刷新页面并删除删除产品,单击opencart标题下拉列表中的删除按钮

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

当我点击opencart标题中下拉菜单上的删除按钮时,我尝试刷新页面以及删除购物车删除数据。 我在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();
            }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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