Jump to content

Display Tax % Rate In Cart & Order Detail?


artofadornment

Recommended Posts

I'm using 1.5.3.1 and I'm hoping there is a way to add the tax % rate to two things: the shopping cart summary (shopping_cart.tpl) and the order detail (order_detail.tpl) views.

 

1.) Currently, the shopping cart shows the label "Total Tax:", but I'd like to have the % rate show beside the label (e.g. "Total Tax 12%:"). No idea how to do this.

 

In fact... since my province (BC, Canada) just switched back to having two sales taxes instead of one, if possible I'd like to be able to show both rates when relevant (e.g. "Total Tax 5% + 7%:"). Since my tax rules are already set up with two rates for BC (state zone ID# 88, if that helps anyone), this should technically be possible. Although if that's too much of a pain to code I can always switch back to having only one rate set for BC (12%) and leave it at that. But the important thing is that any % being charged should display.

 

2.) Currently the order detail view doesn't even have a line for tax, which frankly amazes me (bit of an oversight there), and is an even bigger problem since I have no idea how to add that, never mind how to add the % as well. I may experiment with coping some code from the shopping cart but I suspect that may not work - I'm no developer.

 

Any help you can offer would be greatly appreciated!

 

~ Elaine

Link to comment
Share on other sites

Update: YES!!! I did find a way to add a tax line to order_detail.tpl, it's a little dirty but it works:

 

<tr class="item">
<td colspan="{if $return_allowed || $order->hasProductReturned()}{if $order->hasProductReturned() && $return_allowed}7{else}6{/if}{else}5{/if}">
{l s='Total tax'}: <span class="price-tax">{displayWtPriceWithCurrency price=$order->total_paid - $order->total_paid_tax_excl currency=$currency}</span>
</td>

 

However still no clue how to add the tax %. :/

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

Hello I'm also trying to achieve the same thing, I found in the debug that the $product array contains "rate" which is the numeric value, but this is applied to each product and isn't a global value.

 

so

 

{foreach $products as $product}

{assign var='mastertaxrate' value=$product.rate}

{$mastertaxrate}

{/foreach}

 

returns the VAT rate (no % but you can add that on) for each item in the basket... looking at a better solution but it's a start

Link to comment
Share on other sites

Thanks. :)

However I couldn't get it to work. I tried inserting your code as-is next to the Total Tax label and it broke the entire page. Then tried taking the variable assign out of that spot and putting it among the other variables around line 150 under {foreach $products as $product}, and left only {$mastertaxrate}% next to the label. I got "0%" to show in the cart view, but the actual rate wasn't grabbed. It seems I still need to define something, somewhere...

Edited by artofadornment (see edit history)
Link to comment
Share on other sites

Did some experimenting, and had some limited success. Using $product.tax_rate instead of $product.rate shows the rate for the currently selected delivery address (YAY!), but doesn't update when the delivery address is changed (it just stays the same rate). And that's as far as I can go without more guidance, my knowledge of this stuff stops here. Anyone?

Edited by artofadornment (see edit history)
Link to comment
Share on other sites

  • 8 months later...

hey i resolved that issue  :) .

 

i ill put solution below it may help some one.

 

search this path first :-  Wamp/www/presta1.5/themes/theme799/js/modules/blockcart/ajax-cart.js

 

In ajax-cart.js 

 

Line no 693:  $('.ajax_cart_tax_cost').text (jsonData.taxCost);

 

                                Replace above line with following code

 

                                var subtotal = jsonData.taxCost;

                                var regex = /[+-]?\d+\.\d+/g;

                                var floats = subtotal.match(regex).map(function(v) { return parseFloat(v); });

                                var taxPer=floats/10;

                                $('.ajax_cart_tax_cost').text(taxPer.toFixed(2)+" %");

 

              but this change is apply at only cart not for shopping cart summary at checkout process.

Link to comment
Share on other sites

  • 2 years later...

This helped me and I can confirm it works in Presta v 1.6.1.4. Thank you!

 

Update: YES!!! I did find a way to add a tax line to order_detail.tpl, it's a little dirty but it works:
 

<tr class="item">
<td colspan="{if $return_allowed || $order->hasProductReturned()}{if $order->hasProductReturned() && $return_allowed}7{else}6{/if}{else}5{/if}">
{l s='Total tax'}: <span class="price-tax">{displayWtPriceWithCurrency price=$order->total_paid - $order->total_paid_tax_excl currency=$currency}</span>
</td>
However still no clue how to add the tax %. :/

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...