Skip to main contentSkip to footer

Show discounts at featured module OpenCart 2.3 for free

Rupak Nepali
Share:
Show discounts at featured module OpenCart 2.3 for free

Opencart tip and trick to show discounts at featured products module in Opencart 2.3 for free, download and install and it will show discounts at the featured module.

Click to Download Ocmod file to show discounts at featured module

Go to catalog\language\en-gb\extension\module\featured.php Add following code:

$_['text_discount']   = ' or more ';

Go to catalog\controller\extension\module\featured.php Find the following lines of code:

$data['heading_title'] = $this->language->get('heading_title');

Add the following lines of code:

$data['text_discount'] = $this->language->get('text_discount');

Find the following lines of code:

foreach ($products as $product_id) {
   $product_info = $this->model_catalog_product->getProduct($product_id);

Add the following lines of code:

$discounts = $this->model_catalog_product->getProductDiscounts($product_id);

            $product_info['discounts'] = array();

            foreach ($discounts as $discount) {
                $product_info['discounts'][] = array(
                    'quantity' => $discount['quantity'],
                    'price'    => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency'])
                );
            }

Find the following lines of code:

$data['products'][] = array(
                    'product_id' => $product_info['product_id'],

Just below it, add the following lines of code:

'discounts'=>$product_info['discounts'],

Now go to catalog\view\theme\YOUR_ACTIVE_THEME\template\extension\module\featured.tpl

Find the following lines of code:

 <div class="button-group">
            <button type="button" onclick="cart.add('<?php echo $product['product_id']; ?>');">

Add above it or where ever you want to show but need to inside the product array:

<?php if ($product['discounts']) { ?>
        <ul>
            <hr>
            <?php foreach ($product['discounts'] as $discount) { ?>
            <li><?php echo $discount['quantity']; ?><?php echo $text_discount; ?><?php echo $discount['price']; ?></li>
            <?php } ?>
        </ul>
        <?php } ?>

Comments

Join the conversation and share your thoughts

Leave a Comment

Your comment will be reviewed before publishing.

Be the first to comment on this post!

Innovation

Let's Make Something Amazing Together

We always provide our best creative ideas at the highest level. Tell us about your project and we will make it work.

InnovateBringing innovative solutions to complex problems
AutomateStreamlining processes through automation
DominateLeading the market with exceptional results
Build Smarter and Launch FasterEfficient development for rapid deployment