You are here

function hook_commerce_line_item_rebase_unit_price in Commerce Core 7

Allows you to add additional components to a line item's unit price when the price is being rebased due to a manual adjustment.

When a line item's unit price is adjusted via the line item manager widget, its components need to be recalculated using the given price as the new base price. Otherwise old component data will be used when calculating the total of the order, causing it not to match with the actual line item total.

The function that invokes this hook first sets the base price to the new unit price amount and currency code and allows other modules to add additional components to the new components array as required based on the components of the price from before the edit.

Parameters

&$price: A price array representing the new unit price. New components should be added to this price's data array.

$old_components: The old unit price components array extracted from the line item before the hook is invoked. The unit price on the line item will already be reset at this time, so the components must be preserved in this array.

$line_item: The line item object whose unit price is being rebased.

See also

commerce_line_item_rebase_unit_price()

commerce_price_component_add()

1 function implements hook_commerce_line_item_rebase_unit_price()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

commerce_tax_commerce_line_item_rebase_unit_price in modules/tax/commerce_tax.module
Implements hook_commerce_line_item_rebase_unit_price().
1 invocation of hook_commerce_line_item_rebase_unit_price()
commerce_line_item_rebase_unit_price in modules/line_item/commerce_line_item.module
Recalculates the price components of the given line item's unit price based on its current amount and currency code.

File

modules/line_item/commerce_line_item.api.php, line 191
Hooks provided by the Line Item module.

Code

function hook_commerce_line_item_rebase_unit_price(&$price, $old_components, $line_item) {

  // No example.
}