在产品页面 opencart 2 中显示所有折扣代码

我想在产品页面中显示我的所有折扣优惠,我在后端总共有 5 个优惠


这是代码


    <?php foreach ($discounts as $discount) { ?>

    <?php echo $discount['quantity']; ?><?php echo $text_discount; ?><?php echo $discount['price']; ?><br />

    <?php } ?

但结果是第一个报价被忽略了,它从第二个值开始


http://img2.mukewang.com/6145e6850001a34619211083.jpg

数组的输出是

 Array ( [0] => Array ( [quantity] => 40 [price] => $5.00 ) [1] => Array ( [quantity] => 160 [price] => $4.00 ) [2] => Array ( [quantity] => 320 [price] => $3.90 ) [3] => Array ( [quantity] => 480 [price] => $3.50 ) )

和优惠的后端设置是

http://img3.mukewang.com/6145e6950001930819191081.jpg

有什么办法可以显示所有优惠吗?


MM们
浏览 232回答 2
2回答

MYYA

尝试运行以下命令:<html><head></head><body><-- Other html code --><?php&nbsp; &nbsp;foreach($discounts as $discount) {&nbsp; &nbsp; &nbsp; &nbsp;echo $discount['quantity'] . ' or more '. $discount['price'] .'<br>';&nbsp; &nbsp;&nbsp; &nbsp;}?><-- Other html code --></body></html>

慕仙森

在此处更改public function getProductDiscounts($product_id) {$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "' AND customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND quantity >= 0 AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) ORDER BY quantity ASC, priority ASC, price ASC");return $query->rows;}请AND quantity > 1 改为AND quantity >= 0
打开App,查看更多内容
随时随地看视频慕课网APP