php – Opencart最低订购价格
作者:互联网
我试图在catalog / 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 minimum order price exclude one category
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'));
}
后
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'));
}
而已.
标签:opencart,opencart2-x,php 来源: https://codeday.me/bug/20191007/1867438.html