I want to display all my discount offers in Product page , Total i have 5 offers in back-end
Here is the code
<?php foreach ($discounts as $discount) { ?>
<?php echo $discount['quantity']; ?><?php echo $text_discount; ?><?php echo $discount['price']; ?><br />
<?php } ?
But in a result the 1st offer is getting ignored , its starts from 2nd value
and the output of array is
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 ) )
and the back-end setup for offers is
is there is any way we can display all the offers ?
Change here
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;
}
Please change AND quantity > 1
to AND quantity >= 0