首页 文章

添加购物车并重定向到当前页面后,Opencart quickview关闭

提问于
浏览
-1

我正在使用opencart和我正在使用的主题有一个产品quickview功能,以弹出窗口打开产品

如果我点击一个弹出产品添加到购物车中,而不是在外页更新,但如果我刷新页面购物车更新我想重新导入当前网址后我点击添加到购物车弹出

ajax post数据后的jquery代码是

success: function(json) {
        $('.alert, .text-danger').remove();
        $('.form-group').removeClass('has-error');

        if (json['error']) {
            if (json['error']['option']) {
                for (i in json['error']['option']) {
                    var element = $('#input-option' + i.replace('_', '-'));

                    if (element.parent().hasClass('input-group')) {
                        element.parent().after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
                    } else {
                        element.after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
                    }
                }
            }

            if (json['error']['recurring']) {
                $('select[name=\'recurring_id\']').after('<div class="text-danger">' + json['error']['recurring'] + '</div>');
            }

            // Highlight any found errors
            $('.text-danger').parent().addClass('has-error');
        }

        if (json['success']) {


            $('#notification').html('<div class="alert alert-success">' + json['success'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>');

            $('#cart-total').html(json['total']);

            $('html, body').animate({ scrollTop: 0 }, 'slow');

            $('#cart > ul').load('index.php?route=common/cart/info ul li');
        }
    }
});

如果我使用window.location,则不会删除购物车弹出窗口

如果我使用 window.location.reload(true); 页面将在弹出窗口中刷新

我的网站链接是http://apnakaryana.com/index.php?route=product/category&path=94

单击产品图像或名称以显示左侧的快速视图弹出窗口

1 回答

  • 0

    最后我找到了解决方案,我在弹出窗口中获取文本中的前一个url并使用jquery获取它并使用 window.location 并使用 parameter '_top' 允许重定向到同一窗口并关闭弹出窗口

    $('#notification').html('<div class="alert alert-success">' + json['success'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>');         
    
    $('#cart-total').html(json['total']);
    
    $('html, body').animate({ scrollTop: 0 }, 'slow');
    
    $('#cart > ul').load('index.php?route=common/cart/info ul li');
    
    alert('Product is Added to the cart');
    
    window.open($('#request_url').text(),'_top');
    

相关问题