public function onKlarnaSelectedCalculatePrice(VirtueMartCart $cart, array &$cart_prices, &$cart_prices_name) { if (!($method = $this->selectedThisByMethodId($cart->virtuemart_paymentmethod_id))) { return NULL; // Another method was selected, do nothing } if (!($method = $this->getVmPluginMethod($cart->virtuemart_paymentmethod_id))) { return NULL; } $sessionKlarnaData = $this->getKlarnaSessionData(); if (empty($sessionKlarnaData)) { return NULL; } $cart_prices_name = ''; $cart_prices[$this->_psType . '_tax_id'] = 0; $cart_prices['cost'] = 0; //vmdebug('cart prices', $cart_prices); $this->_getCartAddressCountryCode($cart, $country_code, $countryId, 'country_2_code'); if (strcasecmp($country_code, $sessionKlarnaData->KLARNA_DATA['country']) != 0) { return false; } $paramsName = $this->_psType . '_params'; $address = $this->getCartAddress($cart, $type, false); $shipTo = KlarnaHandler::getShipToAddress($cart); $cart_prices_name = $this->renderKlarnaPluginName($method, $address['virtuemart_country_id'], $shipTo, $cart_prices['withTax']); if ($sessionKlarnaData->klarna_option == 'invoice') { $this->setKlarnaCartPrices($cart, $cart_prices, $method); } return true; }
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'] )); } } } }