Hook: getScalePriceQuantity

Im Zuge der Ermittlung der zugrundeliegende Menge für einen Staffelpreis

/*
 * -- Registration: --
 * $GLOBALS['MERCONIS_HOOKS']['getScalePriceQuantity'][] = array('myMerconisHookClass', 'myGetScalePriceQuantity');
 *
 * -- Invocation: --
 * When detecting the quantity used for the following scale price calculation
 *
 * -- Parameters: --
 *           1. $objProductOrVariant - the product or variant object
 *  2. $type - 'product' or 'variant' to tell whether the hook is called for a product or a variant
 *  3. $cartKey - the product's or the variant's cart key (productID-variantID_configuratorHash)
 *
 * -- Return value: --
 * $scalePriceQuantity - the detected quantity
 *
 * -- Objective: --
 * e.g. implement a custom logic to detect the scale price quantity
 *
 */

public function myGetScalePriceQuantity($objProductOrVariant, $type, $cartKey) {
	$scalePriceQuantity = 0;
	
	/*
	 * Custom code to detect the quantity.
	 *
	 * The cart information in the session should be considered:
	 * $_SESSION['lsShopCart']['items']
	 *
	 * In this example cart items whose product code's first character match,
	 * will be grouped. If the product's settings demand different configurations
	 * to be separated, this is respected in this example.
	 *
	 * the product code has been made available in the cart items' information
	 * using the hook "beforeAddToCart". Please take a look at the hook's example code.
	 */
	
	$arrSplitCartKey = $objProductOrVariant->splitProductVariantID($cartKey);
	foreach ($_SESSION['lsShopCart']['items'] as $itemCartKey => $arrItemInfo) {
		$arrSplitItemCartKey = $objProductOrVariant->splitProductVariantID($itemCartKey);
		if (substr($objProductOrVariant->_code, 0, 1) == substr($arrItemInfo['productCode'], 0, 1)) {
			if ($objProductOrVariant->_scalePriceQuantityDetectionAlwaysSeparateConfigurations && $arrSplitCartKey['configuratorHash'] != $arrSplitItemCartKey['configuratorHash']) {
				continue;
			}
			$scalePriceQuantity = $scalePriceQuantity + $arrItemInfo['quantity'];
		}
	}
	
	return $scalePriceQuantity;
}