Commerce calculated price extras
Categories
Component ID
Component name
Component type
Maintenance status
Development status
Component security advisory coverage
Component created
Component changed
Component body
Warning: This is not really a project in its own right, it contains code that ought to live in Drupal Commerce itself, but I need it right now. It won't ever be promoted to a full project. Feel free to use it, but do so at your own risk!
Drupal Commerce allows different rules to affect the price of a product. The price after these rules are applied is not what's stored in the field data table, and isn't what's used if you select a price field in Views. Commerce supports dynamic price pre-calculation, where every combination of rules is iterated through and the appropriate price is created. This is stored to allow it to be queried later.
I believe work is still needed on Commerce's support for precalculated prices, but it's possible to get Views support for precalculated prices. As of 16 July 2012, a patch is needed from #1020050: Allow Views to sort / filter based on pre-calculated prices to expose the precalculated price table to Views. That allows you to use the precalculated price field as a simple display field, or for sorting. You can (re)calculate the precalculated prices by going to Store -> Configuration -> Product pricing rules -> Pre-calculation and clicking Batch calculate prices now. However as far as I know there's no way to update an individual precalculated price.
This module
- adds a surrogate key to {commerce_calculated_price} (it doesn't have a primary key defined).
- adds a Rules action that takes a product as a parameter and updates its precalculated price.
- provides a rule called Update precalculated price (disabled by default) that recalculates a product's price after it's saved.