Opencart minimum order price

2019-02-16 02:14发布

I am trying to implement below code from here in 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 }  ?> 

but i am getting an error

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

reference taken:

Opencart minimum order price exclude one category

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

2条回答
你好瞎i
2楼-- · 2019-02-16 03:04

The code below is working for me:

    <?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; ?>
查看更多
祖国的老花朵
3楼-- · 2019-02-16 03:10

Not the same way but you can do it like this:

Add this line in your checkout.php controller file.

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

Thats it.

查看更多
登录 后发表回答