Jump to content

[Solved] How to get quantity discount prices to display including tax


neller

Recommended Posts

Hi,

I have quantity discounts on my shop, but in the product.tpl it doesn't show the prices to display including tax, only without prices.

I have modded the quantity discount display to show the actual proce instead of the amount discounted
from;


<td>

{if $quantity_discount.price >= 0 OR $quantity_discount.reduction_type == 'amount'}

-{convertPrice price=$quantity_discount.real_value|floatval}

{else}

-{$quantity_discount.real_value|floatval}%

{/if}

</td>

to


<td>

{if $quantity_discount.price >= 0 OR $quantity_discount.reduction_type == 'amount'}

{convertPrice price=$quantity_discount.price|floatval}

{else}

-{$quantity_discount.real_value|floatval}%

{/if}

</td>

But what I really need is to be able to display the prices including tax.
Does anyone know how this can be achieved?

Regards,
Neller

 

Link to comment
Share on other sites

Here is the solution if anyone else requires this;

 

Add this code to override\controllers\front\ProductController.php (or make the file if it doesn't exist)

 

<?php

class ProductController extends ProductControllerCore
{

   protected function formatQuantityDiscounts($specific_prices, $price, $tax_rate, $ecotax_amount)
   {
       foreach ($specific_prices as $key => &$row)
       {
           $row['quantity'] = &$row['from_quantity'];
           if ($row['price'] >= 0) // The price may be directly set
           {
               $cur_price = (Product::$_taxCalculationMethod == PS_TAX_EXC ? $row['price'] : $row['price'] * (1 + $tax_rate / 100)) + (float)$ecotax_amount;
               $row['price'] = $cur_price;
               if ($row['reduction_type'] == 'amount')
                   $cur_price -= (Product::$_taxCalculationMethod == PS_TAX_INC ? $row['reduction'] : $row['reduction'] / (1 + $tax_rate / 100));
               else
                   $cur_price *= 1 - $row['reduction'];
               $row['real_value'] = $price - $cur_price;
           }
           else
           {
               if ($row['reduction_type'] == 'amount')
                   $row['real_value'] = Product::$_taxCalculationMethod == PS_TAX_INC ? $row['reduction'] : $row['reduction'] / (1 + $tax_rate / 100);
               else
                   $row['real_value'] = $row['reduction'] * 100;
           }
           $row['nextQuantity'] = (isset($specific_prices[$key + 1]) ? (int)$specific_prices[$key + 1]['from_quantity'] : -1);
       }
       return $specific_prices;
   }
}

 

And replace this to themes\blah blah\ product.tpl - around line 487

<td>{$quantity_discount.quantity|intval}</td>
		    <td>
			    {if $quantity_discount.price >= 0 OR $quantity_discount.reduction_type == 'amount'}
				   -{convertPrice price=$quantity_discount.real_value|floatval}
			   {else}
				   -{$quantity_discount.real_value|floatval}%
			   {/if}
		    </td>

 

With this

<td>{$quantity_discount.quantity|intval}</td>
                           <td>{if $quantity_discount.price >= 0 OR $quantity_discount.reduction_type == 'amount'}
                                  <!-- handle tax -->
                                  {*if $tax_enabled*}
                                          {convertPrice price=$quantity_discount.price|floatval}
                                  {*else*}
                                          {*math equation="qprice * tax" qprice=$quantity_discount.price tax=$quantity_discount.tax assign=gross_price*}
                                          {*convertPrice price=$gross_price*}
                                          {*$smarty.const.PS_TAX_EXC*}
                                  {*/if*}                               
                              {else}
                                  -{$quantity_discount.real_value|floatval}%
                              {/if}
                           </td>

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...