Php Opencart最低订购价格

Php Opencart最低订购价格,php,opencart,opencart2.x,Php,Opencart,Opencart2.x,我试图在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"&g

我试图在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 }  ?> 
参考文献:


方法不同,但您可以这样做:

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

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

就是这样。

下面的代码对我有用:

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


您正在使用哪个版本的opencart?如果高于2.0,则您无法直接在tpl文件中执行此操作。@VedPandya是的,它是2.0,那么如何解决此问题在我的情况下不起作用,它不会重定向到cart back。@HardikaSatasiya如果给定的解决方案对您不起作用,请就此提出新问题
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'));
}
    <?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; ?>