需要在opencart 2.3.0.2中添加直接签出,而不是添加到购物车中

需要在opencart 2.3.0.2中添加直接签出,而不是添加到购物车中,opencart,checkout,Opencart,Checkout,opencart的原始代码:- var cart = { 'add': function(product_id, quantity) { $.ajax({ url: 'index.php?route=checkout/cart/add', type: 'post', data: 'product_id=' + product_id + '&quantity=' + (typeof(quanti

opencart的原始代码:-

var cart = {
    'add': function(product_id, quantity) {
        $.ajax({
            url: 'index.php?route=checkout/cart/add',
            type: 'post',
            data: 'product_id=' + product_id + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1),
            dataType: 'json',
            beforeSend: function() {
                $('#cart > button').button('loading');
            },
            complete: function() {
                $('#cart > button').button('reset');
            },
            success: function(json) {
                $('.alert, .text-danger').remove();

                if (json['redirect']) {
                    location = json['redirect'];
                }

                if (json['success']) {
$('#content').parent().before('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');

                    // 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);

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

                    $('#cart > ul').load('index.php?route=common/cart/info ul li');
                }
            },
            error: function(xhr, ajaxOptions, thrownError) {
                alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
            }
        });
    },

有谁能帮我解决这些opencart 2.3.0.2问题吗?

用下面的代码替换已经更改的重定向功能

window.location='index.php?route=checkout/checkout';
使用此代码,这将重定向到您的签出

location.href='index.php?route=checkout/checkout';

这应该行得通,我现在使用的是2.3.0.2,有多个商店在成功声明中使用它,以便在单击“添加到购物车”后重定向到购物车页面

  window.location.href = "index.php?route=checkout/cart"; 
显然,您希望将其更改为:

  window.location.href = "index.php?route=checkout/checkout";

祝你好运

请格式化您的代码。另外,请让OP知道您在回答中提到的语句之间的差异,这将有助于他们理解问题。嘿,Alexander,我必须在哪一页上替换代码?该页位于您的目录/视图/主题/(主题名称)/产品/产品.tpl中您需要查看添加到购物车成功功能(根据您的主题可能会有所不同),它几乎总是在页面底部。您也可以在此处发布javascript函数的内容,我可以提供进一步帮助。嘿,Alexander,谢谢,我这么做了,但仍然存在一个问题,它只在iam位于产品页面时有效,而在iam位于主屏幕或产品列表时无效。请帮助我还有..嘿,萨尔曼,没问题,现在你已经在product.tpl页面上完成了,这很简单。你能告诉我你在这些页面上显示这些产品的模块吗?特色?旋转木马?我必须首先知道。好的,关于特色产品模块,在/catalog/view/theme/(themename)中/extensions/module/featured.tpl您希望做与产品相同的事情。tpl如果这对您有效,您可以对此进行投票或将其标记为答案吗?由于我刚刚开始,我仍然无法确定我能在多大程度上帮助其他分数较低的人。谢谢!
  window.location.href = "index.php?route=checkout/checkout";