5 replies [Last post]
a_c_m@drupal.org's picture
Offline
Bug Finder
Joined: 01/02/2008
Juice: 288
Was this information Helpful?

Today we tried to change how the order total displays. The site is a UK site were users expect to see prices inc. taxes at all points, and only be informed how much of the end total was tax. So currently we have :

Order total
------------
Subtotal :  £16.16
UK shipping : £2.00
Subtotal excluding taxes : £18.16
VAT (tax) : £3.18

Order total : £21.34

But wanted to change it to :

Order total
------------
Subtotal : £17.00
UK shipping : £2.35

Total : £21.34
/ includes VAT (tax) of : £3.18 /

I was hoping this would be simple to do. It wasn't. We had to write the code into 3 places each with slightly different variable names and formatting requirements, one was customer.itpl.php (theme location, fine), another was theme_uc_cart_checkout_review and finally we had to hack uc_payment.module to get the last one!

Not ideal.

A function like this where there is the same data being presented again and again, needs to be changeable from a single point, to stop copy/paste coding Smiling

If i think of a clever way to do this, i will submit a patch, or if anyone else can help - brilliant!

a_c_m

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Order total - code duplication.

A user named Al has been working on a solution that sounds similar to where you're going. He wants to add a step in between loading a node or order and formatting prices that gives modules the chance to affect the price based on rules for things like VAT and discounts. I believe he's been investigating this in conjunction with morten.dk and maybe others, so look for a forum post about it in the near future. Last I heard he was rerolling his changes against the 1.4 release and doing some other related work on it.

a_c_m@drupal.org's picture
Offline
Bug Finder
Joined: 01/02/2008
Juice: 288
Re: Re: Order total - code duplication.

Brilliant! my next post (http://www.ubercart.org/forum/ideas_and_suggestions/6565/better_tax_supp...) was about taxes as well - so looks like were all pulling/thinking in the right direction !!! Hurray !

10o
10o's picture
Offline
Joined: 11/18/2008
Juice: 33
Solution in customer.itpl.php?

I struggled with exactly the same problem and solved it by just adding some php code to the uc_order template 'customer.itpl.php' so the VAT-amount is only shown on the invoice.
So I added this code on the desired place in this file:

<?php
$vat
= 19/119 * $order->order_total;
$vat = round($vat, 2);
echo(
'Including 19% VAT: €' . $vat);
?>

No tax rules in the Übercart settings are necessary now. This of course only applies when all products (and shipping) have the same tax percentage...

a_c_m@drupal.org's picture
Offline
Bug Finder
Joined: 01/02/2008
Juice: 288
Re: Order total - code duplication.

I'm quite shocked to find out that despite the improvements in Ubercart in general in regards to VAT support, this display issue is still not solved. Here is a patch to allow this to happen on the checkout page, but i think i need more to get into the invoice sections.

AttachmentSize
uc_payment-ordertotal-weight.txt 2.17 KB
a_c_m@drupal.org's picture
Offline
Bug Finder
Joined: 01/02/2008
Juice: 288
Re: Order total - code duplication.

Ok, so its actually not that bad. Seems most of the work was already done.

We stilled the payment update, but only one additional change (and only to a iTPL!) - both patches attached.

AttachmentSize
uc_order-ordertotal-weight.txt 2.54 KB
uc_payment-ordertotal-weight.txt 2.17 KB