Post by JonnyW » Mon Feb 21, 2011 8:07 pm

Hi!

I'm doing my first test-build of a opencart store and need to know if I can display prices like this:

Product A
Price ex. VAT: £1200.00
Price inc. VAT: £1600.00

But when the customer goes to check out, they check out with the Ex VAT price.

An example site and product using this is here: http://smartscooters.co.uk/?p=186


Any ideas on how to achieve this really appreciated.

Thank you very much,

Jon.

New member

Posts

Joined
Mon Feb 21, 2011 8:02 pm

Post by SXGuy » Mon Feb 21, 2011 10:36 pm

post removed to save confusion.
Last edited by SXGuy on Wed Feb 23, 2011 9:04 am, edited 1 time in total.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by JonnyW » Wed Feb 23, 2011 6:38 am

Hi,

Thank you very much for the detailed answer.

The reason it's needed is that in the UK, registered disabled people can purchase mobility scooters and walking aids VAT free as long as they have filled out a VAT excemption form on the website.

However, in order to be accepted into the local trading standards group, the inc. VAT price must be displayed as well, regardless of whether or not it's used.

Thanks again!

Jon.

New member

Posts

Joined
Mon Feb 21, 2011 8:02 pm

Post by SXGuy » Wed Feb 23, 2011 9:03 am

Ah! yeah i know of the vat exemption!.

in regards to my previous post, i was under the assumption that opencart used a product price and seperated the vat from it, but this isnt actually the case, infact ive never had to use the tax options before now so i only knew what id read from others, but it seems that all product prices are net values and the tax option adds the vat amount to it.

So please ignore my previous post.

But now knowing what i do this makes it alot simpler actually,

Opencart already takes the product price, and adds the vat to it for the shopping cart purposes.

So if you were to post the cart controller function for adding tax to a product, and place it in your product controller file, you will be able to pull the product data before and after vat is added to the item.

Then it would be simply a case of including the new gross price variable below the <?php echo $price; ?> code inside the product.tpl file.

If i get some time over the next few days, ill look in to this and post the code for you, as its something that may be benificial to others.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by SXGuy » Wed Feb 23, 2011 6:32 pm

ok :)

heres how you display prices excluding vat and including vat on all the category pages.

You can apply the same process, to all the product pages, related product pages, latest product pages etc etc.

The process is exactly the same. Any trouble just pm me and ill walk you through it.

Anyway for products in the category pages....

catalog/controller/product/category.php

find

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')));
Add underneath

Code: Select all

$this->data['text_ex_price'] = $this->language->get('text_ex_price');
$this->data['text_inc_price'] = $this->language->get('text_inc_price');
find

Code: Select all

$this->data['products'][] = array( 
add before );

Code: Select all

'exprice' => $this->currency->format($result['price']),
catalog/engligh/language/product/category.php

find

Code: Select all

$_['text_model_desc']   = 'Model Z - A';
add underneath

Code: Select all

$_['text_ex_price']   = ' Ex Vat';
$_['text_inc_price']   = ' Inc Vat';
catalog/view/theme/YOURTHEME/template/product/category.tpl

find

Code: Select all

<?php if ($display_price) { ?>
add underneath

Code: Select all

<span style="color: #900; font-weight: bold;"><?php echo $products[$j]['exprice']; ?><?php echo $text_ex_price; ?></span><br />
find

Code: Select all

<span style="color: #900; font-weight: bold;"><?php echo $products[$j]['price']; ?></span>
Replace With

Code: Select all

<span style="color: #900; font-weight: bold;"><?php echo $products[$j]['price']; ?><?php echo $text_inc_price; ?></span>
Last edited by SXGuy on Thu Feb 24, 2011 4:33 am, edited 1 time in total.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by Moggin » Wed Feb 23, 2011 10:02 pm

:good: Brilliant SXGuy, thank you. Quite a few people ask for this.

Active Member

Posts

Joined
Wed May 05, 2010 4:56 am

Post by endzX » Wed Mar 09, 2011 11:05 pm

Hey I used theese codes, works great,

One little thing, how do I make my site to calculate vat prices.
My products are written without vat.
http://noexit.sytes.net/veikals

you can check out on category.php I get 1 price in both ex and inc vat.

And yes, I have geo zone and tax rate is 22%.


[EDIT] Excuse my inconvinience! This works great, I solved my problem. I red topic for dummies on Tax/vat/geo zones.

Newbie

Posts

Joined
Wed Mar 09, 2011 10:59 pm

Post by Ljubo » Wed Mar 23, 2011 5:36 am

Hi everyone,

I am having a problem in modifying the files so that they would result in showing the price with and without VAT.
Can anyone, PLEASE, send me or attach here the already modified and working neccessary files?

thank you!

Active Member

Posts

Joined
Mon Jan 31, 2011 10:07 pm
Location - Serbia

Post by i2Paq » Wed Mar 23, 2011 6:17 am

There is a vQmod for this.

Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

Our FREE search: Find your answer FAST!.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by Ljubo » Wed Mar 23, 2011 5:00 pm

Excellent!

Can you please post the link to it since I am having problems in finding it?

Active Member

Posts

Joined
Mon Jan 31, 2011 10:07 pm
Location - Serbia

Post by traceofwind » Thu Mar 24, 2011 1:41 am

Hi,

I too can not find the vqmod for this and yes I have searched theqdomain.com and Google for VAT vqmod.

I think, like me, there are others here who want to *add* 'price inc. VAT' when the site is set to display prices 'exc. VAT' by default. The solution above seems to *add* 'exc. VAT' when the site is set to display 'inc. VAT' by default. How can we access/create a variable for inc. VAT? Essentially, I think we need one line of code along the lines of;

Code: Select all

'INC_VAT_price' => $this->currency->format($result['price'] ????? ),
Any one?

Or if anyone has the link to the vqmod, please share?

Cheers

Gary

New member

Posts

Joined
Fri Jul 02, 2010 6:37 am

Post by SXGuy » Thu Mar 24, 2011 4:01 am

it doesnt work that way as far as i understand it.

opencart adds tax on a product price excluding tax. but only when display prices including tax is set in settings.

so for example, if display price including tax is set to no then

$price = $this->currency->format($this->tax->calculate($result['price'] Would still be the same as the price excluding tax.

its only when the option is set to yes, that it actually adds the tax value to the product price.

So you do have the price excluding tax, and the price including tax, but only when the option to display including tax is set.

Hope that makes sense.

So "display products including tax" should actually say "& add the tax to the product price which is used for the cart/checkout"

What is needed, is the ability to calculate tax on a product, but have two options for settings.

"Displaying prices excluding AND including tax

and

"Set cart price to include taxes"

That way you can display both prices, but yet choose to checkout including or excluding taxes.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by smart81bg » Sun Apr 03, 2011 12:44 am

hello,

how i can use this script to show VAT in product page and catalogue just for current language

Newbie

Posts

Joined
Wed Mar 16, 2011 3:12 am

Post by traceofwind » Sun Apr 10, 2011 11:36 pm

Hi,

Can someone familiar with php and the controller files post something like;

Code: Select all

Price inc. VAT: £<?php echo ($price) * 1.2; ?>
I understand that whilst the OpenCart engine (by default) can't output inc. TAX when 'Show prices inc. tax = no' is set from the admin dashboard, that we could at least implement a very basic line of code on the product.tpl page to show a price inclusive of VAT.

Any one?

Gary

EDIT: for example, in ASP I could write something simple like;

Code: Select all

DIM rs, itax, iprice_inc
rs         = record set of product
itax       = 1.2
iprice_inc = rs("Price")*itax

...

<tr>
   <td>Price including VAT: £<%= iprice_inc %></td>
</tr>
Can we not do something in php, just as a hack to display inc. TAX prices on our product.tpl pages?

New member

Posts

Joined
Fri Jul 02, 2010 6:37 am

Post by JonnyW » Mon May 02, 2011 8:24 pm

SXGuy - I haven't picked up on the build again until now and wanted to thank you for your detailed response! Will try it now and let you know how it went :)

J

New member

Posts

Joined
Mon Feb 21, 2011 8:02 pm

Post by SXGuy » Mon May 02, 2011 8:45 pm

traceofwind wrote:Hi,

Can someone familiar with php and the controller files post something like;

Code: Select all

Price inc. VAT: £<?php echo ($price) * 1.2; ?>
I understand that whilst the OpenCart engine (by default) can't output inc. TAX when 'Show prices inc. tax = no' is set from the admin dashboard, that we could at least implement a very basic line of code on the product.tpl page to show a price inclusive of VAT.

Any one?

Gary

EDIT: for example, in ASP I could write something simple like;

Code: Select all

DIM rs, itax, iprice_inc
rs         = record set of product
itax       = 1.2
iprice_inc = rs("Price")*itax

...

<tr>
   <td>Price including VAT: £<%= iprice_inc %></td>
</tr>
Can we not do something in php, just as a hack to display inc. TAX prices on our product.tpl pages?

you can do this, by modifying the controller file, but it will affect ALL products, and if you set tax, it will multply that by 1.2 also, so be very careful when doing this.

catalog/controller/product/category.php

find

Code: Select all

$this->data['products'][] = array(
            			'name'    => $result['name'],
						'model'   => $result['model'],
            			'rating'  => $rating,
						'stars'   => sprintf($this->language->get('text_stars'), $rating),
						'thumb'   => $this->model_tool_image->resize($image, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')),
            			'price'   => $price,
            			'options' => $options,
						'special' => $special,
						'href'    => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/product&path=' . $this->request->get['path'] . '&product_id=' . $result['product_id']),
						'add'	  => $add
          			);
change $price, $special, $add to

$price * 1.2

for example.

This should work, let me know if you have any problems.

you will also need to do this for all controller files associated with product pages, related pages, etc etc

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by JonnyW » Mon May 02, 2011 9:05 pm

Hi!

The code changes above work for category pages but only when I set the product as Taxable Goods and then, of course, it goes through the checkout as Price inc VAT. When I set the tax class as NONE, the same price (ex vat) is shown for both INC and EX Vat.

http://lemongrasstest.co.uk/smart/index ... ry&path=35

When I make the same code changes for the product pages, I get this on the product page:

http://lemongrasstest.co.uk/smart/index ... duct_id=49

Notice: Undefined variable: j in /home/lemongra/public_html/smart/catalog/view/theme/default/template/product/product.tpl on line 17Notice: Undefined index: in /home/lemongra/public_html/smart/catalog/view/theme/default/template/product/product.tpl on line 17Notice: Undefined variable: text_ex_price in /home/lemongra/public_html/smart/catalog/view/theme/default/template/product/product.tpl on line 17
Price: £984.00
Availability: In Stock
Model: PrideLX
Manufacturer: Pride
Average Rating: Not Rated

Any suggestions?

Thanks again,

Jon.

New member

Posts

Joined
Mon Feb 21, 2011 8:02 pm

Post by SXGuy » Tue May 03, 2011 4:13 am

My first bit of code at the top of the page will only work when a tax class is set. It can not work without it.
The most recent code I posted should work without a tax class set.
And as for your errors my advise is u didn't follow the changes correctly. If u tried to apply it to other pages then the php output variables need to look the same as the rest used on that page

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by DrJohn » Wed Sep 21, 2011 11:48 pm

I tried to find the code that sxGuy mentioned in the third or fourth reply to this thread, to add before and after vat prices but I can't find $discount (and hence the correct place to add the extra code) in the category.php file in version 1.5.

Is there an updated version of this code or editing instructions for v1.5 ? Or has my client edited it out perhaps when configuring the cart?

New member

Posts

Joined
Wed Sep 21, 2011 11:22 pm

Post by SXGuy » Thu Sep 22, 2011 2:00 am

JonnyW wrote:Hi!

The code changes above work for category pages but only when I set the product as Taxable Goods and then, of course, it goes through the checkout as Price inc VAT. When I set the tax class as NONE, the same price (ex vat) is shown for both INC and EX Vat.

http://lemongrasstest.co.uk/smart/index ... ry&path=35

When I make the same code changes for the product pages, I get this on the product page:

http://lemongrasstest.co.uk/smart/index ... duct_id=49

Notice: Undefined variable: j in /home/lemongra/public_html/smart/catalog/view/theme/default/template/product/product.tpl on line 17Notice: Undefined index: in /home/lemongra/public_html/smart/catalog/view/theme/default/template/product/product.tpl on line 17Notice: Undefined variable: text_ex_price in /home/lemongra/public_html/smart/catalog/view/theme/default/template/product/product.tpl on line 17
Price: £984.00
Availability: In Stock
Model: PrideLX
Manufacturer: Pride
Average Rating: Not Rated

Any suggestions?

Thanks again,

Jon.

The same price will show when you disable prices with tax, because, there is no tax function to calculate a seperate price.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am
Who is online

Users browsing this forum: No registered users and 16 guests