public static
getCartDiscountPriceForProduct
(mixed $productId, mixed $categoryId, mixed &$priceItems)
/*
* Specific case: global cart discount will be displayed in category, item or items view
* but under specific rules like: only percentage, no total amount, no minimum quantity rule !!!
* Display the cart discount price in category, items or product view
*/
public static function getCartDiscountPriceForProduct($productId, $categoryId, &$priceItems)
{
$paramsC = PhocacartUtils::getComponentParameters();
$display_discount_cart_product_views = $paramsC->get('display_discount_cart_product_views', 0);
if ($display_discount_cart_product_views == 0) {
return false;
}
// DISABLED FOR
// when calculation is fixed amount (we cannot divide the discount into products which are not in checkout cart)
// when rule TOTAL AMOUNT is active (displaying products is not checkout to check the total amount)
// when rule MINIMUM QUANTITY is active (displaying products is not checkout to check the minimum quantity)
$discount = self::getCartDiscount($productId, $categoryId, 0, 0);
if (isset($discount['discount']) && isset($discount['calculation_type'])) {
$priceItems['bruttotxt'] = $discount['title'];
$priceItems['nettotxt'] = $discount['title'];
$quantity = 1;
//Quantity for displaying the price in items,category and product view is always 1
$total = array();
// not used in product view
if ($discount['calculation_type'] == 0) {
// FIXED AMOUNT
// Fixed amount cannot be divided into product in views (category, items, item)
// this is the opposite to checkout where we can divide fixed amount to all products added to cart
$priceItems = array();
return false;
} else {
// PERCENTAGE
PhocacartCalculation::calculateDiscountPercentage($discount['discount'], $quantity, $priceItems, $total);
}
PhocacartCalculation::correctItemsIfNull($priceItems);
PhocacartCalculation::formatItems($priceItems);
return true;
}
$priceItems = array();
return false;
}