function hook_commerce_price_component_type_info in Commerce Core 7
Defines price component types for use in price component arrays.
The price field data array includes a components array that keeps track of the various components of a price that result in the price field's current amount. A price field's amount column reflects the sum of all of its components. Each component includes a component type and a price array representing the amount, currency code, and data of the component.
The Price module defines three default price component types:
- Base price: generally used to represent a product's base price as derived from the product itself and manipulated by Rules; appears in price component lists as the Subtotal
- Discount: used for generic discounts applied by Rules
- Fee: used for generic fees applied by Rules
The Tax module also defines a price component type for each tax rate that requests it.
The price component type array structure includes the following keys:
- name: the machine-name of the price component type
- title: the translatable title of the price component for use in administrative displays
- display_title: the translatable display title of the price component for use in front end display; defaults to the title
- weight: the sort order of the price component type for use in listings of combined price components contained in a price's components array
Return value
An array of price component type arrays keyed by name.
2 functions implement hook_commerce_price_component_type_info()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- commerce_price_commerce_price_component_type_info in modules/
price/ commerce_price.module - Implements hook_commerce_price_component_type_info().
- commerce_tax_commerce_price_component_type_info in modules/
tax/ commerce_tax.module - Implements hook_commerce_price_component_type_info().
1 invocation of hook_commerce_price_component_type_info()
- commerce_price_component_types in modules/
price/ commerce_price.module - Returns a list of all available price component types.
File
- modules/
price/ commerce_price.api.php, line 64 - Hooks provided by the Price module.
Code
function hook_commerce_price_component_type_info() {
return array(
'base_price' => array(
'title' => t('Base price'),
'display_title' => t('Subtotal'),
'weight' => -50,
),
'discount' => array(
'title' => t('Discount'),
'weight' => -10,
),
'fee' => array(
'title' => t('Fee'),
'weight' => -20,
),
);
}