/** * @return array */ public function getMethods() { if ($this->methods !== null) { return $this->methods; } // $this->methods = parent::getMethods(); $allowedMethods = $this->getAllowedMethods(); // All Methods are allowed if ($allowedMethods === true) { return $this->methods; } $result = array(); foreach ($this->methods as $method) { /** * @var $method Mage_Payment_Model_Method_Abstract */ $methodAvailable = $allowedMethods->getData($method->getCode()); if ($methodAvailable == 1) { $result[] = $method; } } // Overwrite Methods with the above created result array $this->methods = $result; return $this->methods; }
/** * Retrieve availale payment methods * * @return array */ public function getMethods() { // Get payment methods form scoring session. if (false == Mage::getModel('scoring/session')->hasSolvencyGroup()) { return parent::getMethods(); } $methods = Mage::getModel('scoring/session')->getSolvencyValidationResultArray(); $result = array(); // Check allowed payment methods and retrieve availale payment methods. foreach (parent::getMethods() as $method) { // Hide payment methods, which are not allowed exists in scoring session. if (false == isset($methods['allowed_payment_methods']) || in_array($method->getCode(), $methods['allowed_payment_methods'])) { $result[] = $method; } } return $result; }
/** * Retrieve available payment methods * The method is redefined to show only Zero Subtotal Checkout (free) payment * method when total value (it includes discount) is zero * * @return array */ public function getMethods() { if (($methods = $this->getData('methods')) !== null) { return $methods; } $methods = parent::getMethods(); if (!($methods && $this->getQuote()->getBaseGrandTotal() == 0)) { return $methods; } $_methods = array(); foreach ($methods as $method) { if ($method->getCode() == 'free') { $_methods[] = $method; break; } } $this->setData('methods', $_methods); return $_methods; }