function uc_discounts_get_discounted_price_for_product in Ubercart Discounts (Alternative) 6.2
Same name and namespace in other branches
- 7.2 uc_discounts/uc_discounts.module \uc_discounts_get_discounted_price_for_product()
Helper function that gets the codeless discounted price of a product
Parameters
$product A node product:
$return_null Return NULL for the price if there are no discounts. Otherwise it returns the sell_price:
2 calls to uc_discounts_get_discounted_price_for_product()
- discounted_price_handler::render in product_price_alterer_field/
includes/ discounted_price_handler.inc - product_price_alterer_field_field in product_price_alterer_field/
product_price_alterer_field.module - Implementation of hook_field()
File
- uc_discounts/
uc_discounts.module, line 1825
Code
function uc_discounts_get_discounted_price_for_product($product, $return_null = TRUE) {
$discounts = get_codeless_discounts_for_product_and_quantity($product, 1);
if (empty($discounts)) {
return $return_null ? NULL : $product->sell_price;
}
$total_discount_amount = 0;
foreach ($discounts as $discount) {
$total_discount_amount += $discount->amount;
}
return $product->sell_price - $total_discount_amount;
}