为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

PHP
MM们 2021-09-18 21:15:20
我想在产品页面中显示我的所有折扣优惠,我在后端总共有 5 个优惠这是代码    <?php foreach ($discounts as $discount) { ?>    <?php echo $discount['quantity']; ?><?php echo $text_discount; ?><?php echo $discount['price']; ?><br />    <?php } ?但结果是第一个报价被忽略了,它从第二个值开始数组的输出是 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 ) )和优惠的后端设置是有什么办法可以显示所有优惠吗?
查看完整描述

2 回答

?
MYYA

TA贡献1868条经验 获得超4个赞

尝试运行以下命令:


<html>

<head></head>

<body>


<-- Other html code -->


<?php

   foreach($discounts as $discount) {

       echo $discount['quantity'] . ' or more '. $discount['price'] .'<br>';   

   }

?>


<-- Other html code -->


</body>

</html>


查看完整回答
反对 回复 2021-09-18
?
慕仙森

TA贡献1827条经验 获得超8个赞

在此处更改


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


查看完整回答
反对 回复 2021-09-18
  • 2 回答
  • 0 关注
  • 231 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信