function hook_commerce_product_calculate_sell_price in Commerce Core 7
Allow modules to alter the product line item during sell price calculation when the "Product pricing process" is configured to either "rules_invoke_all" or "module_invoke_all".
Parameters
$line_item: The product line item used for sell price calculation.
File
- modules/
product_pricing/ commerce_product_pricing.api.php, line 87 - Hooks provided by the Product Pricing module.
Code
function hook_commerce_product_calculate_sell_price($line_item) {
$line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
$product = $line_item_wrapper->commerce_product
->value();
// If the product is not published, nullify the line item's unit price.
if (!$product->status) {
$line_item_wrapper->commerce_unit_price->amount = NULL;
return;
}
}