function product_price_alterer_field_field in Ubercart Discounts (Alternative) 7.2
Same name and namespace in other branches
- 6.2 product_price_alterer_field/product_price_alterer_field.module \product_price_alterer_field_field()
Implementation of hook_field()
File
- product_price_alterer_field/
product_price_alterer_field.module, line 77 - Provides discounts based on ubercart products based on product quantity purchased using attached product field.
Code
function product_price_alterer_field_field($op, &$node, $field, &$items, $teaser, $page) {
switch ($op) {
case "sanitize":
case "view":
//If items is empty, generate value by getting discounts that apply to this product
if (empty($items)) {
$discounted_price = uc_discounts_get_discounted_price_for_product($node);
if (!is_null($discounted_price)) {
//Add field for discounted price
$item = array();
$item["discounted_price"] = theme("product_discounted_price", $node, uc_currency_format($discounted_price));
$items[] = $item;
add_product_price_altering_css($node);
add_product_price_altering_javascript($node);
}
}
break;
}
}