Discount price in Featured products
Posted: Wed Dec 14, 2016 2:30 am
I am new to Opencart and I am trying to display the quantity discount in the featured products - without success. I am using Opencart 2.3. Basically, what I would like to achieve is to pass the variables quantity and price from the controller file featured.php to the view file featured.tpl.
Here is what I have tried:
1) In the file /catalog/controller/extension/module/featured.php after the I added the following code:
2) In the file /catalog/view/theme/default/template/extension/module/featured.tpl I added the following code:
Any help would be very much appreciated!
Here is what I have tried:
1) In the file /catalog/controller/extension/module/featured.php after the
Code: Select all
$product_info = $this->model_catalog_product->getProduct($product_id);
Code: Select all
$discounts = $this->model_catalog_product->getProductDiscounts($product_id);
$data['discounts'][] = array();
foreach ($discounts as $discount) {
$data['discounts'][] = array(
'quantity' => $discount['quantity'],
'price' => $discount['price']
);
}
Code: Select all
<?php foreach ($discounts as $discount) { ?>
<span>
<?php echo sprintf($text_discount, $discount['quantity'], $discount['price']); ?>
</span><br>
<?php } ?>