2

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

谢谢,
伊拉克利斯

4

4 回答 4

1

(这适用于 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';
}

祝你好运

于 2015-03-12T07:19:01.067 回答
0

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

对于类别页面 \catalog\view\theme\default\template\product\category.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>

产品页面 \catalog\view\theme\default\template\product\product.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> 
于 2015-03-16T06:19:22.603 回答
0

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

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

希望有帮助

于 2012-11-18T00:36:53.773 回答
0

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

我加了

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

归档 opencart/upload/catalog/view/javascript/common.js 第 168 行。

它就像魅力一样。

于 2016-12-30T18:53:18.690 回答