Jump to content

Order summary discount amount update


Recommended Posts

Greetings, i added total discount amount to the order sumary, but when i change the amount of the product the discount amount remains the same unless i refresh the page. I know this can be fixed with the cart-summary.js but i have no clue how. Can someone please guide me how to do this? i really apreciate it.

 

This is how i added the discount total:

 

So first, we will need to customize the template ‘shopping-cart.tpl’

 

{assign var='totalReductonPercent' value=0}
{assign var='totalReductonValue' value=0}
{foreach $products as $product}
      {assign var='totalReductonValue' value=$totalReductonValue + $product.price_without_specific_price * $product.quantity}
{/foreach}
{assign var='totalReductonPercent' value=(($totalReductonValue - $total_products) / $totalReductonValue) * 100}
 

 

We will use the following code to output the total discount in the shopping cart:

   
<tr class="cart_total_discount">
    <td colspan="3" class="text-right">{l s='Total discount'}</td>
    <td colspan="2" class="price" id="total_discount">
        {convertPrice price=$totalReductonValue - $total_products}<br>
        <span class="price-percent-reduction small">{($totalReductonPercent)|round|string_format:"%d"}%</span><br>
    </td>
</tr>

 

 

To correctly output html, you need to take into account this additional line that displays the total sum of the discount:

 

<td rowspan="{4+$total_discounts_num+$use_show_taxes+$total_wrapping_taxes_num}" colspan="3" id="cart_voucher" class="cart_voucher">
   
Link to comment
Share on other sites

×
×
  • Create New...