Opencart最低下单价

2024-02-15

我正在尝试在 Catalogue/view/theme/default/template/checkout/confirm.tpl 中实现以下代码

<?php if ($this->cart->getSubtotal() >= 1000) { ?>
<div id="payment"><?php echo $payment; ?></div>
<?php } else { ?>
<div class="warning">Minimum 10 Euro to checkout</div>
<?php }  ?> 

但我收到错误

Notice: Undefined property: Loader::$cart in C:\xampp\htdocs\optest\catalog\view\theme\default\template\checkout\confirm.tpl on line 51
Fatal error: Call to a member function getSubtotal() on null in C:\xampp\htdocs\optest\catalog\view\theme\default\template\checkout\confirm.tpl on line 51

参考资料:

Opencart最低下单价不包括一类 https://stackoverflow.com/questions/20042912/opencart-minimum-order-price-exclude-one-category

http://forum.opencart.com/viewtopic.php?t=53810 http://forum.opencart.com/viewtopic.php?t=53810


方式不一样,但你可以这样做:

在 checkout.php 控制器文件中添加此行。

if ($this->cart->getSubtotal() < 1000) {
    $this->session->data['error'] = 'Your warning message';
    $this->response->redirect($this->url->link('checkout/cart'));
}

After

if ((!$this->cart->hasProducts() && empty($this->session->data['vouchers'])) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) {
    $this->response->redirect($this->url->link('checkout/cart'));
}

就是这样。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Opencart最低下单价 的相关文章

随机推荐