I installed the latest version because I needed the tax stuff (#399586: cha0s' attempt to solve the VAT display stuff), but the prices are still shown without VAT, I'm using <?php print theme('uc_product_price',$node->sell_price, 'sell-price', $no_label = 1) ?> but to be honest, I have no idea if this is the way to go?

Comments

Island Usurper’s picture

I suppose theme_uc_product_price() is actually deprecated, since it was replaced by uc_price() and it wasn't updated to use it.

Try using this code:


  $context = array(
    'location' => 'product-view', // You may want to customize this value to indicate that you are using a custom template. Your call.
    'class' => array(
      'product',
      'sell',
    ),
    'subject' => array(
      'node' => $node,
      'field' => 'sell_price',
    ),
  );

  print uc_price($node->sell_price, $context, array('label' => FALSE));

Now, I haven't seen that anyone has made a VAT module that uses the price handlers yet since it's still very new. You shouldn't actually see a difference in the price yet, unless you've got more code than I know about.

attiks’s picture

It's working with the discount framework, but how can I do the same inside a views tpl.php file. The view only contains the title + sell price fields, so I don't have a node I can pass?

Is there any documentation on the context options, I checked uc_price.inc but it's still not clear (i couldn't find anything on the subject parameter).

Cheers
Peter

attiks’s picture

Another 'problem', I want to be able to display both the regular price and the discount price on my node, does uc_price support this in any way?

Island Usurper’s picture

The price field handler should be running the value through uc_price() on its own already. I've tried to fake a node object, but it only has the values that are selected by the View. You'll have to figure out what your discounts need to know about the node, and add that data as fields. You can then exclude those fields from being displayed. Not everything will work this way (I'm particularly thinking of taxonomy terms) since they aren't attached to the node through node_load() and it has a different structure.

You can get the original value by calling uc_price() again with the same parameters, except changing the "revision" key of the $context. The full list of revisions is
- 'original' => Original price value,
- 'altered' => Original price passed through the alterer(s),
- 'formatted-original' => Original price passed through the formatter,
- 'formatted' => Altered price passed through the formatter,
- 'themed-original' => Formatted original price passed through the theme layer,
- 'themed' => Formatted altered price passed through the theme layer.

attiks’s picture

Theming the original price is working by using 'themed-original', but I'm afraid I'm going to run into a problem:
I'm going to use the same mechanism (CA) for discounts and for taxes, but I need to be able to display the original price inlcuding taxes as well as the discount price including taxes. Is there a way to do this, can I specify which alterers to use (by class)?

Concerning the views problem, any ideas how to solve this, because the discounts will be managed based on the taxonomy (or is it easier/better to use CCK?), I know I can add the nid the the fields and do a full load in my theme function, but it is a bit over-kill.

shiroitatsu’s picture

subscribing

Island Usurper’s picture

So, I'm going back on what I said about theme_uc_product_price(). It's no longer deprecated, but it's signature has changed to look like

  function theme_uc_product_price($price, $context, $options = array());

These parameters are passed directly to uc_price(), so to suppress the label, you should add 'label' => FALSE to $options.

The reason for doing this was to allow the product view page to wrap the prices in block-level divs like it used to. theme_uc_price() only outputs spans which made the products look odd.

It was hinted at, but never discussed thoroughly to record the amount of each alteration to a price. That wouldn't be very hard to do, especially since it's up to the alterers to do that.

rszrama’s picture

Issue tags: +theme layer, +price, +ubercamp sprint

Tagging.

Island Usurper’s picture

Status: Active » Fixed

Yeah, this is done. And, in fact, there is a uc_vat module that changes the way prices are displayed.

Status: Fixed » Closed (fixed)
Issue tags: -theme layer, -price, -ubercamp sprint

Automatically closed -- issue fixed for 2 weeks with no activity.