OpenCart 跳过“添加到购物车”,直接结帐


OpenCart skip "Add to cart", straight to checkout

我想知道是否可以跳过OpenCart中特定产品的"添加到购物车"步骤,当用户单击它们时,将他直接发送到结帐页面。但仅适用于特定产品。

谢谢
伊拉克利斯

(这适用于 opencart 1.5.2.x 和 1.5.3.x)

编辑文件:catalog/view/theme/yourtheme/template/product/product.tpl 并进行以下修改:

查找代码:

if (json['success']) {
window.location='index.php?route=checkout/cart';
}

替换为以下代码:

if (json['success']) {
window.location='index.php?route=checkout/checkout';
}

祝你好运

我认为要做到这一点,您必须向管理员添加一个复选框,以记下您希望跳过该步骤的项目。然后,这将为您提供需要跳过的项目列表。

添加到购物车时,在 Ajax 调用 php 脚本中放置一个查询,它正在添加到购物车中,从这里您可以获取产品 ID 并检查这是否是要跳过的项目之一,如果是,您可以标题重定向到结帐。

希望有帮助

对于 opencart 2.0在添加到购物车按钮旁边添加额外的按钮,即立即购买或者,您可以在管理员中添加必须立即购买的产品或添加到购物车按钮

的选项

对于类别页面''目录''视图''主题''默认''模板''产品''类别.tpl模块也是如此

<button type="button" onclick="buynow('<?php echo $product['product_id']; ?>');">
     <i class="fa"></i> 
     <span class="hidden-xs hidden-sm hidden-md">Buy Now</span>
     </button> 
     <script>function buynow(pid){cart.add_buynow(pid);}</script>

对于产品页面''目录''视图''主题''默认''模板''产品''产品.tpl

<button type="button" id="button_buy" data-loading-text="<?php echo $text_loading; ?>" class="btn btn-primary btn-lg btn-block">Buy Now</button>

<script>
$("#button_buy").click(function(){
  $.ajax({
    url: 'index.php?route=checkout/cart/add',
    type: 'post',
    data: $('#product input[type=''text''], #product input[type=''hidden''], #product input[type=''radio'']:checked, #product input[type=''checkbox'']:checked, #product select, #product textarea'),
    dataType: 'json',
    beforeSend: function() {
      $('#button-buy').button('loading');
    },    
    complete: function() {
      $('#loading-image').html('');
    },
    success: function(json) {
      $('.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']) {location.href = 'index.php?route=checkout/checkout';  }
    }
  });
});
</script> 

我正在使用OpenCart 2.3.0.2.可能这对某人有帮助吗

我添加了

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

到 file opencart/upload/catalog/view/javascript/common.js第168行。

它就像魅力一样工作。