Usage of a price formatter

4 replies [Last post]
Joined: 04/02/2009
Juice: 27

Hello,

the documentation in uc_store/includes/uc_price.inc is as follows:

The heart of the price modification/displaying system,
this function handles price alteration, formatting, theming, and caching.

That´s why I assume that a price formatter should be used to add something like "excl. VAT" to each price. Is my assumption correct? If the answer to this question is "yes" then I would like to know why the $context variable, which is passed to a price alterer, is not passed to a price formatter. In my opinion it is important to have the $context variable available in the price formatter as well. What do you think? Thanx for a reply.

fmueller

Joined: 08/07/2007
Juice: 6673

Yes, I'd say that's the kind of thing formatters should be used for. I'm very surprised that they don't get the $context. Once I've caught up with everything, I'll post a patch to fix it.

Joined: 04/02/2009
Juice: 27

Are there already any news about this one? It would be really great to have this feature available since here in Germany we must add a note to each price that tax is included.

Joined: 02/04/2010
Juice: 2

It would be very nice, to patch this in the ubercart core - as one has to hack core to make it work.

It's in /uc_store/includes/uc_price.inc
line 155 and 156 and should look like this

      $values['formatted-original'] = $handlers['formatter']($values['original'], $options, $context);
      $values['formatted'] = $handlers['formatter']($values['altered'], $options, $context);

instead of

      $values['formatted-original'] = $handlers['formatter']($values['original'], $options);
      $values['formatted'] = $handlers['formatter']($values['altered'], $options);

Adding the $context variable had no side effects for the existing formatter handler uc_store_price_handler_format in my test environment.

Thanks for your work!
Anschinsan

Joined: 04/02/2009
Juice: 27

Hi,

that is exactly what I have described last year at http://www.ubercart.org/forum/support/14785/adjust_price_formatting_only.... And I am still waiting for advice on how this should be done in the most elegant way. With "this" I mean "adjusting price formatting only on a few places".

Thanx for your reply Anschinsan and for bringing this topic up again.

fmueller