I am using OC version 3.0.3.8 and trying to display discount on product page by subtracting special from price. Here are the modifications that I have made:
In catalog\controller\product\product.php
After this line:
Code: Select all
$special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
Code: Select all
$disPercentage = ((($result['price']-$result['special'])/$result['price']) * 100);
$disPrice = $result['price']-$result['special'];
Code: Select all
$special = false;
Code: Select all
$disPercentage = false;
$disPrice = false;
Code: Select all
$data['special'] = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
Code: Select all
$disPercentage = ((($product_info['price']-$product_info['special'])/$product_info['price']) * 100);
$disPrice = $product_info['price']-$product_info['special'];
And finally, after this line:
Code: Select all
'special' => $special,
Code: Select all
'disPercentage' => $disPercentage,
'disPrice' => $disPrice,
After this line:
Code: Select all
<li><a class="thumbnail" href="{{ popup }}" title="{{ heading_title }}"><img src="{{ thumb }}" title="{{ heading_title }}" alt="{{ heading_title }}" /></a></li>
Code: Select all
{% if special %}
<div style="position: absolute;
top: 10px;
left: 10px;
background-color: red;
font-weight: 600;
font-size: 14px;
color: white;
padding: 5px 10px;
border-radius: 0px 20px 20px 0px;
/* transform: rotate(-45deg); */
z-index: 99;">
$ {{ disPrice }} off
</div>
{% endif %}
disPrice is not getting value from controller to twig.
I have tried clearing cache from modification page, from blue gear in dashboard, from system/storage but to no avail. I am still not getting anything. I have tried hardcoding disPrice in controller to eliminate if there is any error in calculation, still noting. If I replace disPrice with special in twig, I get special price string.
I have applied same modification on category.php and category.twig and it works.
Please help