Example #1
0
	function plgVmOnCheckoutAdvertise ($cart, &$payment_advertise) {

		$vendorId = 1;
		$loadScriptAndCss = FALSE;
		if (!class_exists ('Klarna_payments')) {
			require (JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'helpers' . DS . 'klarna_payments.php');
		}
		$country_code = NULL;
		$countryId = 0;
		if ($this->getPluginMethods ($cart->vendorId) === 0) {
			return FALSE;
		}

		$this->_getCountryCode ($cart, $country_code, $countryId);
		foreach ($this->methods as $method) {
			if ($cart->virtuemart_paymentmethod_id == $method->virtuemart_paymentmethod_id) {
				continue;
			}
			if (!($cData = $this->checkCountryCondition ($method, $country_code, $cart))) {
				return NULL;
			}
			if (strtolower ($country_code) == 'nld') {
				//  Since 12/09/12: merchants can sell goods with Klarna Invoice up to thousands of euros. So the price check has been moved here
				if (!KlarnaHandler::checkPartNLpriceCondition ($cart)) {
					// We can't show our payment options for Dutch customers
					// if price exceeds 250 euro. Will be replaced with ILT in
					// the future.
					return NULL;
				}
			}
			if (in_array ('part', $cData['payments_activated'])) {
				$payments = new klarna_payments($cData, KlarnaHandler::getShipToAddress ($cart));

				// TODO: change to there is a function in the API
				$sFee = $payments->getCheapestMonthlyCost ($cart, $cData);
				if ($sFee) {
					$payment_advertise[] = $this->renderByLayout ('cart_advertisement',
						array("sFee"   => $sFee,
							  "eid"    => $cData['eid'],
							  "country"=> $cData['country_code']
						));
				}
			}
		}

	}