Hook: checkIfPaymentOrShippingMethodIsAllowed

Bei der Ermittlung der erlaubten Zahlungs- und Versandmethode

/*
 * -- Registration: --
 * $GLOBALS['MERCONIS_HOOKS']['checkIfPaymentOrShippingMethodIsAllowed'][] = array('myMerconisHookClass', 'myCheckIfPaymentOrShippingMethodIsAllowed');
 *
 * -- Invocation: --
 * When it's checked whether a payment or shipping method is allowed. If
 * the standard checks performed by the Merconis core already determined that
 * a method is not allowed, this hook will not be called for this specific method.
 *
 *
 * -- Parameters: --
 *	1. $arr_method - an array holding the method info
 *	2. $str_type - the method type (shipping or payment)
 *  
 * -- Return value: --
 * $bln_methodIsAllowed - true if the method is allowed, false if it's not
 *
 * -- Objective: --
 * implement custom rules defining when a method is allowed
 *
 */

public function myCheckIfPaymentOrShippingMethodIsAllowed($arr_method, $str_type) {

	/*
	 * If the logic of this function depends on customer data, e.g. the customers postal code, we can get it like this:
	 *
	 * $this->import('ls_shop_checkoutData');
	 * $customerPostalCode = $this->ls_shop_checkoutData->arrCheckoutData['arrCustomerData']['postal']['value'];
	 */
	
	/*
	 * If the logic of this function depends on the current cart calculation, we can get it like this:
	 *
	 * $this->import('ls_shop_cartX');
	 * $calculation = $this->ls_shop_cartX->calculation;
	 */
	
	/*
	 * If the logic of this function depends on specific details of the products that are currently contained in the cart,
	 * we can get this information like this:
	 *
	 * $this->import('ls_shop_cartX');
	 * $cartItems = $this->ls_shop_cartX->itemsExtended;
	 * foreach ($cartItems as $cartItem) {
	 *  	// $cartItem['objProduct'] holds a product object that can be used just like the product object available e.g. in product details templates.
	 * 		$productTitle = $cartItem['objProduct']->_title;
	 * }
	 *
	 */
	
	/*
	 * This hook function gets called every time a method information for a
	 * shipping or payment method is requested. If we only want to deal with
	 * a specific shipping method, we have to abort this function by returning
	 * true if the currently requested method is not the one we want
	 */
	
	if ($str_type != 'shipping' || $arr_method['id'] != 1) {
		return true;
	}
	
	/*
	 * For example, we can allow the method only if it is between 18 pm and 20 pm
	 */
	
	if (date(G) < 18 || date(G) > 20) {
		return false;
	}
	
	return true;
}