Hi there,
This module allow to add taxes amount to product prices if a tax is defined for a product.
You can define which role can see product prices with tax and which can't...
Version 1.2.1
Correct a bug that can appear cause of the shortcut user to get the node types.
Version 1.2
New
- Change used access, now, you have to specify which role have price excluding VAT and not the price including VAT, so you have to inverse your role access setting I find this way of thinking more logical.
- Rounded values fixed, now prices with tax are rounded to avoid the $8.99 or $9.01 amount.
- Message is displayed under the cart and under the payment pane in the checkout to explain that the rounded amount can cause little differences between price displayed in the cart and price displayed in the checkout. (I ask how to proceed to an accountant, it sait do me that it was current, so don't worry)
- little things I don't remember

For people that used custom PHP conditions in their tax setting and upgraded to alpha8, I suggest you to remove your taxe rule and create a new one because it can cause problems
Version 1.1
A small bug corrected that the price added to cart with product attributes was wrong. And a correction of rounded value is done too.
How does it work
When you see a product, the module check if the role have the right to see product with tax included, if yes, it check all taxes applied to the product and add them to the price.
So you can continue to manage your products without taxes. When you add a new product to your store, you have to enter the price without Taxes in the sell price field.
The tax is added to the product price in the product listing, product details and the cart. In the checkout page, the tax is removed to show the product prices without tax because discount and other stuff have to be calculated on without tax prices.
So you can test and tell me what is usefull / useless.... enjoy
| Attachment | Size |
|---|---|
| uc_taxes_price.zip | 1.85 KB |
| uc_taxes_price1.1.zip | 1.88 KB |
| uc_taxes_price1.2.zip | 1.79 KB |
| uc_taxes_price1.2.1.zip | 2.11 KB |


Re: Add tax to product price
thx for this contribution, would be really helpful for me. when i first tried to install it, i got the following error:
parse error, unexpected T_OBJECT_OPERATOR in /var/www/web8/html/modules/ubercart/contrib/uc_taxes_price/uc_taxes_price.module on line 143i looked at the line and changed
$type = node_get_types('type', $node)->type;to
$type = node_get_types('type', $node->type);maybe just a typo?
now i don't geterrors anymore, but am also not able to get the shop to display the prices with the tax applied. would be great if you could take a look into this, i'm sure thats no big thing
ah yeah, i set "add vat price to product price"-permission for any role. thank you very much
...sebi
Re: Re: Add tax to product price
k, sry hat was stupid, pls ignore my last post... i looked up the api and saw that node_get_types expects an input in form of

node_get_types($op, $node, $reset)anyways, i got it to work by adding an additional step to determine the "type's type"
the whole function now looks like this in my installation and seems to work for me:
function _uc_product_taxes_calculate($node) {$gettype = node_get_types('type', $node);
$type = $gettype->type;
$taxes = uc_taxes_get_rates();
foreach ($taxes as $taxe) {
foreach ($taxe->taxed_product_types as $taxed_product_type) {
if($type == $taxed_product_type) {
$taxes_amount += $taxe->rate;
}
}
}
return $taxes_amount;
}
Re: Re: Re: Add tax to product price
I will look through my package for errors and will repost a full new package very soon.
Re: Re: Re: Add tax to product price
Thank you sebi, it seems it works for me too.
---
Edit: No, on checkout page the tax is not included!
@zmove: Thank you very much. It would be really nice get this feature working.
br vs net
"the tax is removed to show the product prices without tax because discount and other stuff have to be calculated on without tax prices."
Well, that's true, but could it be calculated in the background and just display br price (or both) at the cart?
If user wants to see details, he/she can check all discounts and whatever at checkout + from the invoice.
What do you think?
Best regards,
Zsigmond
@green: this is normal
@green:
this is normal behaviour because of discounts being added on the checkout page. i suggest you
1. turn off the "shopping cart"-block for "cart/checkout" and "cart/checkout/*" in drupal's block configuration
2. go to "store administration->configuration->checkout settings->edit->checkout panes" and disable "cart contents".
3. if you translate your shop, you can just overwrite "Subtotal" with "Subtotal (net)" in your language...
a little hacky, i know, but it satisfies my needs
have a good time
...sebi
Re: Add tax to product price
Hi there, and thank you for your answer.
I will post today a new little version that correct some problems.
For the price excluding vat on the checkout page, the problem is that Ubercart don't provide hook to alter the subtotal, and the subtotal is calculated by adding the product price * quantity in the cart.
So, to alter the subtotal I'm obliged to alter the cart, that's why I return to excluding price in the checkout page.
As it said below (and this is the way I proceed), the best way ATM is to disable the cart block in the checkout page, and change the title to the cart pane to specify that prices are excluding VAT.
I will improve that when Ubercart will provide these functionnalities because it's a think I don't really like too.
Edit : New version updated
Re: Re: Add tax to product price
Hi zmove, thank you for you patch! But if i upload uc_taxes_price.module i get the same error again: (on all pages)
Parse error: parse error, unexpected T_OBJECT_OPERATOR in /var/www/web2/html/sites/all/modules/ubercart/contrib/uc_taxes_price/uc_taxes_price.module on line 165
and there is:
<?phpfunction _uc_product_taxes_calculate($node) {
$type = node_get_types('type', $node)->type;
?>
Re: Re: Re: Add tax to product price
Strange, this is not a code error,
writing the instruction below is exactly the same think that the folowing instruction
<?php
$type = node_get_types('type', $node);
$node_type = $type->type;
?>
But it's written in only one line... what version of PHP do you use ? I have PHP5, maybe this shortcut is not compatible with previous version of PHP...
I correct this shortcut to correct this error, download the 1.2.1 version
Re: Re: Re: Re: Add tax to product price
this could be the reason, i'm using php 4.3.10-22.
Re: Re: Re: Re: Add tax to product price
maybe this is the reason, i'm using php 4.3.10-18 and also 1.2.1 does not work.
Re: Re: Re: Re: Re: Add tax to product price
Strange, I tested it on a php4 install and it works. It is a clean ubercart installation ?
Did you give the right access to see product with tax in the access control of drupal ?
Hi, I don't think that's a
Hi,
I don't think that's a solution for me
Net and/or Br (= Net + TAX) price should be shown...
hook_form_alter and multiple attribute problem
Hi, first of all thanks for your work.
no let's go for some problem,
If 'uc_attribute_option_price_format' is set to 'total' your form_alter (uc_taxes_price_form_alter) works, it creates the $form['attributes'] with taxes, but it doesn't override the _uc_attribute_alter_form, so the attribut price is still without vat ...
in case of 'adjustment' it's the same, and i think you forgot to set vat, it'll be something like that :
$display_price = ($option->price != 0 ? ', '. ($option->price > 0 ? '+' : '') . uc_currency_format($option->price + ($option->price * _uc_product_taxes_calculate($node)),2) : '');Then i got a strange problem with your module when setting 2 attribut for a product, the second attribut will be add twice to the price ... but i think it could come from the problem with the hook_form_alter.
regards
Mog
Hi, It begin to be a long
Hi,
It begin to be a long time I worked on that module, and I don't exactly all the code.
For your first problem, try to put a higher weight to my module than the core attribute module in the system table.
My store works with 'total' uc_attribute_option_price_format, and it works, but I may have to change the weight as I said above.
for the second problem, I think it could have the same origin because the core attribute function make a += to calculate price, and in my module, I initialize variable to avoid this problem.
If you still have these problems after updating the module weight in the system table, give me feedback again.
Re: Hi,
Great, now it works, thanks a lot, i didn't know the trick of system table to overide hook, i feel less stupid now !
It still have problem with multiple attribute, but i find where it come from :
line 122,
$item->price += $op_prices;was not in the foreach, so it takes only the last option price.
And i still get my proposition to get option price with vat in case of adjustment :
line 68 insert,
$option->price = $option->price + ($option->price * _uc_product_taxes_calculate($node));$option->price = round($option->price, 2);
regards
Mog
Re: Re: Hi,
Ok thank you for your patch, I don't have multi attributes product and as I'm lazy, I didn't test them. I will try your code and release a new package if it works well.
Adding a product WITH taxes
Hi,
thanks zmove for your contribution, works well with my client's store.
I have couple suggestions for this module:
1) The product price should be able to have the choice if it's added including or excluding taxes. (example image attached)
In business-to-business shops the VAT exclusion is ok, but when dealing with business-to-customer, the VAT/taxes are not that critical to know. I't actually a real pain to first decide what the customer-price is and then calculate the tax manually. But the tax separation should still be shown in the checkout panes.
2) If the product is added with tax, then the taxes should be calculated EVERYWHERE, even the checkout review-pane. I had to override some functions in order to get it work...
But great job so far! I'd be glad to help in testing & debugging if needed.
Hi, Thanks for your
Hi,
Thanks for your feedback.
At the moment, I don't need the functionnality to add product price including tax, and I think I will not need for a long time. I develop store for french customer and in france, prices are calculated without tax.
But this is a good idea to make the module more extensible, and I think I will add it in my TODO list.
But my priority at the moment is to work on userpoint integration with ubercart and some others functionnalities and I will not have time to do it in short term, so if you need it quickly, I will enjoy to help you to improve the module and add it in official release if the code satisfy my quality criteria.
How to use this?
May I'm just a stupid beginner, but I don't know how to include this function at all.
I put this module to "modules/ubercard/contrib/uc_taxes_price/uc_taxes_price.module" but nothing happend and I can't see any options in access control or elsewhere about. How can I activate this function ? I'm using ubercard beta 5...
I would be very happy if anybode can help me, cause this is the last issue I have with my shop. I need prices shown including VAT.
Thanks for any help
Jürgen
Does not work with beta 5
Ok, I AM just a stupid beginner
I found out, that the info-files was missing in latest release. Now I can see and activate the module and the options in access control.
But if I add a product to the cart a blank page appears when I'm not logged in.
....
g
Jürgen
Re: Add tax to product price
I reup tha 1.2.1 with the .info file, on my ubercart installation, it works with beta 5...
Re: Does not work with beta 5
But if I add a product to the cart a blank page appears when I'm not logged in.
hi Jügen blank pages are often the sign of PHP running out Memory.. or any other PHP issues have you checked your error logs maybe they have some Information that could help you / us to solve your Problem.
uc_views_handler
Hi,
Now with last ubercart release you have new block "special offers" and "best sellers", but it seems to use views handler to display product field.
uc_product.module line 1173
function uc_views_handler_priceand so it doesn't take care of uc_taxes change to display price and i don't find how to hook this views hook (?) without modifying uc_product.module
if anyone has an idea ...
regards
Mog
Re: uc_views_handler
I had the same problem with a special offer view I created...
To show product price including tax, I themed my view, and in the view.tpl.php file, for the price field, I added the tax to the product for the good roles.
To get the tax you can use _uc_product_taxes_calculate() function (see in the module). After that, it's pretty easy to make the simple calculation to add the tax to product price.
Not working into UCb6
This contrib isn't working into a beta6 version. Prices still the same...
Re: Not working into UCb6
hmmm, did you set the role that have to see product with vat included ?
role assignment on UCb6
Yes I've two roles for backoffice and common registered users in frontoffice.
I've seen in the last release that privs are for NOT showing VAT prices, so I've checked only for backoffice roles. My contrib version is latest till now (1.2.1)
Allowing all product classes
Just tried installing this useful-looking module, but didn't find any of my displayed prices changing. After realising that I was logged in with the super user account (uid = 1) (doh!) I then logged out but found that anonymous users *still* saw ex-VAT prices.
I am not using any node types of "product", but rather a set of Ubercart classes, so I think this modifcation needs to be made in this case (works fine for me now anyway):
function uc_taxes_price_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
if (!user_access('pricing without vat')) {
// Lookup all product classes
$classes = db_query("SELECT pcid FROM {uc_product_classes}");
$ok = false;
while ($class = db_fetch_array($classes)) {
if ($node->type == $class[0]) {
$ok = true;
break;
}
}
if (!($ok || $node->type != 'product')) {
return;
}
switch ($op) {
case 'prepare':
$sell_price = $node->sell_price / (1 + _uc_product_taxes_calculate($node));
$node->sell_price = round($sell_price, 2);
break;
case 'load':
$sell_price = $node->sell_price + ($node->sell_price * _uc_product_taxes_calculate($node));
$node->sell_price = round($sell_price, 2);
break;
}
}
}
I have basically just changed the first part of the function. Hope it makes sense and helps someone else.
Regards,
- Paul
Hi, It appear that recent
Hi,
It appear that recent changes in ubercart beta 6 breaks this module, I don't have time ATM to see what to change in my module to make it work on the latest beta 7.
I will be able to work on it in 1 month (I have a big project that take all my time for 1 month),
After that, I will make my module compatible with the latest ubercart release (1.0 ?
).
So, be patient or post a patch ^^'
Round to 1
Just round to 1 and not 2 to avoid .01 and .99 ¢ prices...
Re: Add tax to product price
This module breaks horribly with uc_product_kit. The only solution I could find is to modify uc_product so that it simply displays prices with VAT directly. I think the best way to get this feature for Ubercart is to simply build it into the core.
Some functions, like views tables with products, don't even have any hooks available to allow a developer to modify the prices in his own module.
Update
I've spent this morning implementing this module. I found a few issues with it,
So i've hacked about with it, and added a few bits, quick break down as follows (patch from 1.2.1 and full copy attached).
I changed.
Still a few issues like the cart block showing prices ex-vat when on the checkout, but i think we will work around this. There is also a bit of a killer one, which is this module needs to have a weight greater than the main uc_taxes module, else its form_alter changes get overwritten by that module. To fix this, simply increase the modules weight in the system table. I did it by hand, but someone should/could submit a patch for it to update as part of the module install.
Enjoy.
Interested to hear feedback.
Drayen
--
acmconsulting.eu
Re: Update
Thank you for your improvement guy.
I don't have time to test it, but I will thrust the communtity, if the reply about your patch are good I will make it core.
Re: Upate
@Drayen: Thank you for your work, the phptemplate_ thing was a nice and useful lesson for me! BTW we could solve the cart block the same.
I see more issues, as - at least in Europe we should until the Subtotal/Total and in order summaries always display taxes:
So I think this we could provide as regular updates until the feature freeze is over.
- Has someone a clue how to modify the product price (through a module) in uc_order_order_pane.inc in function uc_order_pane_products($op, $arg1) / case 'customer' without changing the subtotal?
- Any ideas how to modify the two mentioned shipping costs?
Any help would be greatly appreciated as this topic slowly drives me crazy...
Best regards,
Al
sponsor of development
Hi. I'd like to sponsor the development of this contrib. Is someone interested? Please PM me.
We urgently need this feature. In short:
- enter sell prices without tax
- have 2 different VAT rates (10 and 19) per product, ability to set it for each product
- display and sell products with VAT
- assistance to get it working right
Thank you.
@borgo: I have partially
@borgo:
I have partially implemented this module as a patch for Ubercart 'core' to make it work reliable on all fields. The module as available here currently does not (and, unfortunately, cannot) adjust prices in views (e.g. listings of products).
Re: Add tax to product price
Is this module valid for someone using RC4 ?
And whats the best version of the module?
Hi, Yes, it doesn't work for
Hi,
Yes, it doesn't work for view. You have to theme your view field to call the function that add tax to the price to make it work. I think with a little code, the module could add a price with tax as a new view field. I'm don't know development for view, maybe somebody can confirm this ?
For the RC4 compatibility, I think with the different patches it could be done, not sure I'm still on the beta 5 ^^