Page 1 of 1
display both EX vat and inc Vat prices
Posted: Sun Jun 20, 2010 5:56 am
by tabletpcsuperstore
hi,
i know there has been brief discussion on this topic but I am trying to set my opencart shop (great program by the way)

to display both the excluding VAT and including vat (tax) price so when a customer visits they see both the prices. its important that online shops in my field show this as business's claim their tax back in the UK so they focus always on just the excluding VAT price, consumers pay the vat however, if i show just the ex vat prices id be upsetting the consumers at the checkout stage, if i just display the including tax prices id be scaring away by business and international customers.
any patch/extentions/codes for this? its very common practice so im sure someone, somewhere has figured this one out.
thanks in advance.
james.

Re: display both EX vat and inc Vat prices
Posted: Sun Jun 20, 2010 6:22 am
by SteveSherry
I have set this up in the past as an additional currency.
i.e. £ ex vat = 1.00000
£ inc vat = 1.1750000
That way the customers have the drop down box @ the top of the screen showing inc & ex vat
Re: display both EX vat and inc Vat prices
Posted: Mon Jun 21, 2010 3:45 am
by Moggin
The drop down is a very good idea: a quick way to show a different shopfront to, say, the consumer and the B2B customer.
However, like James, I'd like to show the price as £xx (£xy+VAT) on the product page. This will suit our market better, if it's possible. Can anyone show us how to do this? Or do I need a commercial mod. Many thanks for any help.
Re: display both EX vat and inc Vat prices
Posted: Mon Jun 21, 2010 4:43 am
by tabletpcsuperstore
@ stevesherry
thanks for the advise and in theory this works well but in practice this has problems.... customer changes current to says inc vat (1.7500000) all good no problem.
customer adds to cart.
customer pays 1.7500000 + 17.5 as the cart has to add vat.
pays double vat
i am pretty sure someone somewhere has made a mod/extention for this its pretty basic requirement.
Re: display both EX vat and inc Vat prices
Posted: Tue Jun 22, 2010 4:18 am
by Moggin
I’ve got this half–working:
....lifted the code from another post and made an educated guess where to put it.
So in
catalog/controller/product/product.php look for:
Code: Select all
else {
$this->data['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
AFTER, add
Code: Select all
//### CUSTOM ### price exc vat
$this->data['price_exvat'] = $this->currency->format($this->tax->calculate($product_info['price'], 0, 0));
..from
CRAZY-Ivan’s post
Then go to
catalog/view/theme/YOUR_THEME/template/product/product.tpl
Find
Code: Select all
<td><b><?php echo $text_price; ?></b></td>
<td><?php if (!$special) { ?>
<?php echo $price; ?>
AFTER, add
Code: Select all
(<?php echo $price_exvat; ?> + VAT)
However, note:
- 1. That’s just for a plain vanilla price – no coding has been changed for sale/strikethrough prices.
2. Only shows on the product page - category level prices are still one VAT inclusive price.
3. The (xx + VAT) is hardcoded into the product.tpl. If you have zero VAT items you’d probably need to put ‘excl VAT’ or whatever.
4. I haven’t got it to play nicely with my Options Price Update mod yet (a true gem from theqdomain.com)
5. I’m not a PHP coder. Use at your own risk: and tell me how to improve/correct it, if you are a coder. Please, backup first. If it doesn't work for you I probably won't know why...
..but it's a start. Thanks and credit to CRAZY-Ivan.
Re: display both EX vat and inc Vat prices
Posted: Wed Jul 21, 2010 6:30 pm
by speedingorange
Can anyone tell me what i would change on this to make it work in reverse. So it displays the Price inc VAT in the brackets.
I tried the obvious of switching around the price and price_exvat but it did not work just displayed 0.00 for both. lol
Re: display both EX vat and inc Vat prices
Posted: Fri Jul 30, 2010 2:58 pm
by Miguelito
I've now done this - I mean price + price excluding vat.
Had to change product, category controller files and their view-files (tpl) + latest module. Now it seems to do the job... though to be perfect also need to edit bestseller module if need to show price exluding vat price in there.
Not a pretty thing but tackles the requirements of B2B customers (price excl. VAT)

Re: display both EX vat and inc Vat prices
Posted: Sun Aug 01, 2010 9:45 pm
by Moggin
Miguelito wrote:I've now done this - I mean price + price excluding vat.
Had to change product, category controller files and their view-files (tpl) + latest module. Now it seems to do the job... though to be perfect also need to edit bestseller module if need to show price exluding vat price in there.
Not a pretty thing but tackles the requirements of B2B customers (price excl. VAT)

Sounds good, Miguelito. Any chance of sharing an example of the code you used in the category controller files, in case anyone wants to do the same thing?
speedingorange - I went back to showing prices without VAT - via the admin panel (System > Settings > Display items with tax: no). I tried, but had no luck showing the VAT-inclusive price in the brackets: maybe someone else will help.
Re: display both EX vat and inc Vat prices
Posted: Tue Aug 10, 2010 9:54 pm
by silanli_53
Moggin wrote:I’ve got this half–working:
....lifted the code from another post and made an educated guess where to put it.
So in
catalog/controller/product/product.php look for:
Code: Select all
else {
$this->data['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
AFTER, add
Code: Select all
//### CUSTOM ### price exc vat
$this->data['price_exvat'] = $this->currency->format($this->tax->calculate($product_info['price'], 0, 0));
..from
CRAZY-Ivan’s post
Then go to
catalog/view/theme/YOUR_THEME/template/product/product.tpl
Find
Code: Select all
<td><b><?php echo $text_price; ?></b></td>
<td><?php if (!$special) { ?>
<?php echo $price; ?>
AFTER, add
Code: Select all
(<?php echo $price_exvat; ?> + VAT)
However, note:
- 1. That’s just for a plain vanilla price – no coding has been changed for sale/strikethrough prices.
2. Only shows on the product page - category level prices are still one VAT inclusive price.
3. The (xx + VAT) is hardcoded into the product.tpl. If you have zero VAT items you’d probably need to put ‘excl VAT’ or whatever.
4. I haven’t got it to play nicely with my Options Price Update mod yet (a true gem from theqdomain.com)
5. I’m not a PHP coder. Use at your own risk: and tell me how to improve/correct it, if you are a coder. Please, backup first. If it doesn't work for you I probably won't know why...
..but it's a start. Thanks and credit to CRAZY-Ivan.
Error..
Code: Select all
(Notice: Undefined variable: price_exvat in /home/******/public_html/catalog/view/theme/default/template/product/product.tpl on line 22 + VAT)
help
thanks
best regarts
Re: display both EX vat and inc Vat prices
Posted: Wed Aug 11, 2010 6:20 pm
by Miguelito
You need to put that code before the else statement.
Re: display both EX vat and inc Vat prices
Posted: Mon Aug 16, 2010 8:30 am
by silanli_53
Thank you. bugs me
How do we integrate these codes to 148b homepage.
Code: Select all
if ($discount) {
$price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], $this->config->get('config_tax')));
} else {
$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
$special = $this->model_catalog_product->getProductSpecial($result['product_id']);
if ($special) {
$special = $this->currency->format($this->tax->calculate($special, $result['tax_class_id'], $this->config->get('config_tax')));
}
}
Re: display both EX vat and inc Vat prices
Posted: Tue Nov 16, 2010 10:08 pm
by deeve
This is a very confusing thread!
Would it be possible for someone to re-cap precisely what code needs to be put where?
One person says place before the 'else' statement, the other says after ..but precisely what & where?
Thanks.
Re: display both EX vat and inc Vat prices
Posted: Thu Nov 18, 2010 4:32 am
by Moggin
Hi deeve - I'll try to clarify. This was a few months ago, and I changed my template again not long afterwards.
Firstly, I was working on version 1.4.8. It may not work on another version of Opencart.
Secondly, I made only 2 changes: one to
catalog/controller/product/product.php - which requires the block of code indicated to be added.
The other is a change to the template, in the file
catalog/view/theme/YOUR_THEME/template/product/product.tpl.
The code that needs to be changed is indicated in the posting.
Miguelito knows more about coding than I do - so if he says the code should go before the 'else' statement, I would try his way first!
Please note also that it was a first try, by a PHP noob! You might prefer to ask one of the experts on here for some paid help, to get the effect you need.
Re: display both EX vat and inc Vat prices
Posted: Wed Jan 05, 2011 7:48 pm
by JM6891
Does anyone know how to display this on the Category page. I can't seem to find where to declare the variable in the controller (I'm a PHP newbie).
Thanks in advance
Re: display both EX vat and inc Vat prices
Posted: Wed Mar 02, 2011 10:56 pm
by piper
As mentioned above, if someone could please clarify the definitive solution to achieve this,
starting with the product.php file. What is the code and where does it have to be added. The same
goes for the product.tpl and any other files. I wonder if Miguelito could lay it out step by step.
Much appreciated.
Final comment. I do find it very strange the absence of such a basic requirement as this. Do
you think the author is aware of this ?
Re: display both EX vat and inc Vat prices
Posted: Wed Mar 02, 2011 11:33 pm
by Moggin
Re: display both EX vat and inc Vat prices
Posted: Thu Mar 03, 2011 1:39 am
by SXGuy
As Moggin stated, i posted a solution already, it applies to the category pages, but you can use the same method for all pages which display prices, as well as modules