Opencart快速查看添加购物车后关闭并重定向到当前页面


Opencart quickview close after add cart and redirect to current page

我使用的是opencart,我使用的主题有一个产品快速查看功能,可以在弹出的中打开产品

如果我点击一个弹出的产品被添加到购物车中,而没有在外部页面中更新,但如果我刷新页面,购物车被更新,我想在我点击弹出中的添加到购物后重定向到当前url

ajax发布数据后的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&路径=94

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

最后我找到了解决方案,我在弹出窗口中获取文本中的上一个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');