For demo, first check the site
http://www.starpetshub.com/

You save price code in opencart

I have managed to show the You Save in modules as well but i have hard-code it so we have to change in the controller of each module and in the product controller and the category controller. To make it work we have

Edit or insert product -> click on Special tab -> add your special price amount -> then  save it
Go to your site and click on the product. you should see a regular and discounted value -> with the discounted amount and you save

First i am going to show how to insert the “You Save” in the category page.

=================

Find the following line of codes in the catalog/controller/product/category.php

if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
 $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
 } else {
 $price = false;
 }

and paste the following code

 
 $save =$this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')) -$this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')));
and on the same page
$this->data['products'][] = array(
 'product_id' => $result['product_id'],
 'thumb' => $image,
 'name' => $result['name'],
 'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
 'price' => $price,
 'special' => $special,
 'save' => $save,
 'tax' => $tax,
 'rating' => $result['rating'],
 'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
 'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'])
 );
insert the 'save' => $save, as in the above in the product array.
Now go to the catalog/view/theme/default/template/product/category.tpl and replace the price section and paste the following and things work out in the category page.
<?php if ($product['price']) { ?>
 <div class="price">
 <?php if (!$product['special']) { ?>
 <?php echo $product['price']; ?>
 <?php } else { ?>
 <span class="price-old">Retail Price: <?php echo $product['price']; ?></span><br /> <span class="price-new"><b>Our Price:<?php echo $product['special']; ?></b> <br />You Save:<?php echo $product['save']; ?> </span>
 <?php } ?>
 <?php if ($product['tax']) { ?>
 <br />
 <span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
 <?php } ?>
 </div>
 <?php } ?>

=====================

Now for the featured module

Find the following line of codes in the catalog/controller/module/featured.php

if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
 $price = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
 } else {
 $price = false;
 }
and paste the following code
 $save =$this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')) -$this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')));
and on the same page
$this->data['products'][] = array(
 'product_id' => $product_info['product_id'],
 'thumb' => $image,
 'name' => $product_info['name'],
 'price' => $price,
 'special' => $special,
 'save' => $save,
 'rating' => $rating,
 'reviews' => sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']),
 'href' => $this->url->link('product/product', 'product_id=' . $product_info['product_id']),
 );
insert the 'save' => $save, as in the above in the product array.
Now go to the catalog/view/theme/default/template/module/featured.tpl and replace the price section and paste the following and things work out in the category page.
<?php if ($product['price']) { ?>
 <div class="price">
 <?php if (!$product['special']) { ?>
 Our Price:<?php echo $product['price']; ?>
 <?php } else { ?>
 <span class="price-old">Retail Price: <?php echo $product['price']; ?></span><br /> <span class="price-new"><b>Our Price:<?php echo $product['special']; ?></b> <br />You Save:<?php echo $product['save']; ?> </span>
 <?php } ?>
 </div>
 <?php } ?>

 

Likewise you can make the changes in the latest module, category module, special module, make same changes as in the featured module and things will work like in the demo site.

I have become quite lazy so i have not make the language and other setting if i become free then i will make the free module for you all till then take care with the above coding style 🙂

 

I forget to search this at first i now find this which is very helpful for you

http://forum.opencart.com/viewtopic.php?f=131&t=39597

You can directly download the module here

http://forum.opencart.com/download/file.php?id=6861 

 

 

amount that costumer saves, right under the price, when there is a special price for the product, shows the amount in amount that costumer saves, customer save modules, You save this module for all modules, discount % or amount of $ right under the picture on front page modules

 

1 COMMENT

  1. Thanks so much for great info, following with you to find out if you get the chance to build the module, same as in your demo ?

    regrds

LEAVE A REPLY

Please enter your comment!
Please enter your name here