You are here

function commerce_product_pricing_commerce_price_field_calculation_options in Commerce Core 7

Implements hook_commerce_price_field_calculation_options().

To accommodate dynamic sell price calculation on the display level, we depend on display formatter settings to alert the module when to calculate a price. However, by default all price fields are set to show the original price as loaded with no option to change this. This module needs to add its own option to the list so it can know which prices should be calculated on display.

See also

commerce_product_pricing_commerce_price_field_formatter_prepare_view()

File

modules/product_pricing/commerce_product_pricing.module, line 41
Enables Rules based product sell price calculation for dynamic product pricing.

Code

function commerce_product_pricing_commerce_price_field_calculation_options($field, $instance, $view_mode) {

  // If this is a single value purchase price field attached to a product...
  if (($instance['entity_type'] == 'commerce_product' || $field['entity_types'] == array(
    'commerce_product',
  )) && $field['field_name'] == 'commerce_price' && $field['cardinality'] == 1) {
    return array(
      'calculated_sell_price' => t('Display the calculated sell price for the current user.'),
    );
  }
}