Jump to content

How to display VAT in order templates


nasos75

Recommended Posts

WHMCS has an option to define tax in your prices as inclusive or exclusive. So, let's say you have a product which you sell for 100 euros + 20% VAT. If you choose the inclusive method, your clients will see the the product's price 120 euros in the order form and 100 + 20 in the cart process. If you choose the exclusive method, your clients will see the product's price 100 euros in the order form and 100 + 20 in the cart checkout process.

 

Personally, I wanted to display the price excluding VAT (so I chose the exclusive method) but I wanted my clients to be aware of the VAT value or total price before checking out. I made that with two methods, in templates/web20cart/products.tpl (change web20cart and products.tpl for your installation accordingly).

 

Find the {foreach key=num item=product from=$products} line, and bellow that line are the definitions for one-time/monthly/etc prices. So, let's say we want to change the yearly price:

 

Change the line {if $product.pricing.annually}{$product.pricing.annually}<br /> with:

 

Method 1: {if $product.pricing.annually}{$product.pricing.annually} {php} $myvar=$this->get_template_vars('product'); $this->assign('vatvalue',number_format($myvar["pricing"]["rawpricing"]["annually"]*0.20,2,',','.')); {/php} (+ €{$vatvalue} {$LANG.vat})<br />

 

Method 2: {if $product.pricing.annually}{$product.pricing.annually} (+ €{math equation="x * 0.20" x=$product.pricing.rawpricing.annually format="%.2f"} {$LANG.vat})<br />

 

In both methods, the $LANG.vat variable is the word VAT in my language files. The advantage of the first method is that you can define number_format with plain php but is more complex, and the advantage of the second method is that you can not define the number format (comma in decimals instead of dot) but is simpler. In the same way, you can change any other template for any other product.

 

I hope I helped! :-)

Link to comment
Share on other sites

  • 11 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated