uc_price() calls the formatter with only a numeric value and the site-wide formatting options:

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

The formatter callback doesn't get the $context data and so knows nothing about what kind of price is being formatted.

This is causing problems in my contrib module http://drupal.org/project/uc_notforsale -- the formatter there needs to return nothing if the price is zero on a product, but a zero shipping cost should always show something.

Comments

longwave’s picture

Status: Active » Closed (won't fix)

This is unlikely to be fixed at this stage. But I think you could implement a price alterer that stores data in $options, which is then available in the formatter. There is a $price_info['placeholder'] that may also be useful for this case.