I use the Commerce price by components module to display products' commerce_price field with tax and discount included. It works as expected (I'm displaying the products' prices with a view in a panel)

I have another field, which is a Computed field, that I use to calculate the discount between the commerce_price field and a custom price field (MSRP).

Unfortunately, while the commerce_price is displayed with tax and discount included, the value sent to the computed field (from the commerce_price token) is the original value, without tax or discount applied, or any information related to the price components.

I can't figure out a clean way to apply the tax and the discount to the commerce_field value used for the calculation in the Computed field. How can I make the computed field receive the same token value as the one displayed?

I'm aware of the module Drupal Commerce Extra Price Formatters but using the Computed field gives me way more flexibility to calculate discount and special prices captions.

1 Answer 1


Surprising I did not find this function before, but this is what I needed:

commerce_product_calculate_sell_price($product, $precalc = FALSE)

Returns a price field data array as returned by entity_metadata_wrapper().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.