2015-10-15 58 views
1

我想从这里目录/视图/主题/默认/模板/结算/ confirm.tplOpencart的最低订单价格

<?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

+0

这Opencart的您正在使用的版本?如果它高于2.0,那么你不能直接在你的tpl文件中这样做。 –

+0

@VedPandya是它的2.0,那么如何解决这个问题 –

回答

9

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

在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')); 
    } 

完蛋了。

0

下面的代码为我工作:

<?php if($this->session->data['currency'] == 'USD') : ?> 
     <?php if($this->cart->getSubtotal() < 2enter code here0) : ?> 
     <div class="warning"><center><?php echo $text_comandamin_eur; ?></center></div> 
     <?php endif; ?> 
    <?php } elseif($this->session->data['currency'] == 'INR') : ?> 
     <?php if($this->cart->getSubtotal() < 1000) : ?> 
     <div class="warning"><center><?php echo $text_comandamin_ron; ?></center></div> 
     <?php endif; ?> 
    <?php endif; ?>