function hook_commerce_price_field_calculation_options in Commerce Core 7
Defines options for the calculation setting of a price field display formatter.
Parameters
$field: The field info array the display formatter is for.
$instance: The instance info array the display formatter is for.
$view_mode: The view mode whose display formatter settings should be used on render.
Return value
An array of key / value pairs for use in a select list options array.
1 function implements hook_commerce_price_field_calculation_options()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- commerce_product_pricing_commerce_price_field_calculation_options in modules/
product_pricing/ commerce_product_pricing.module - Implements hook_commerce_price_field_calculation_options().
1 invocation of hook_commerce_price_field_calculation_options()
- commerce_price_field_formatter_settings_form in modules/
price/ commerce_price.module - Implements hook_field_formatter_settings_form().
File
- modules/
price/ commerce_price.api.php, line 22 - Hooks provided by the Price module.
Code
function hook_commerce_price_field_calculation_options($field, $instance, $view_mode) {
// This example from the Product Pricing module adds an option for the display
// formatter to specify the calculated sell price for use in the display.
// 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.'),
);
}
}