public function isAvailable($quote = null) { $isAvailable = parent::isAvailable($quote); Mage::getSingleton('core/session', array('name' => 'adminhtml')); $apiRunning = Mage::getSingleton('api/server')->getAdapter() != null; if ($apiRunning || Mage::getSingleton('admin/session')->isLoggedIn()) { return $isAvailable; } if (Mage::getSingleton('customer/session')->isLoggedIn()) { $helper = Mage::helper('emjainteractive_purchaseordermanagement'); $customer = Mage::getSingleton('customer/session')->getCustomer(); $poLimit = $customer->getPoLimit() ? $customer->getPoLimit() : $helper->getDefaultPoLimit(); $cartTotal = Mage::getModel('checkout/cart')->getQuote()->getGrandTotal(); $allowedCustomerGroups = $helper->getAllowedCustomerGroups(); $allowedCustomerGroups = explode(',', $allowedCustomerGroups); if (!in_array($customer->getGroupId(), $allowedCustomerGroups)) { $isAvailable = false; } if (!$poLimit) { $isAvailable = false; } elseif ($poLimit < $cartTotal) { $isAvailable = false; } } else { $isAvailable = false; } return $isAvailable; }
/** * Validate payment method information object * * @param Mage_Payment_Model_Info $info * @return Mage_Payment_Model_Abstract */ public function validate() { if (AW_Sarp_Model_Subscription::isIterating()) { if (!self::$poIsset) { $info = $this->getInfoInstance(); if ($info) { $poNumber = $info->getData('po_number'); if ($poNumber) { $info->setPoNumber($poNumber . '-' . Mage::getModel('core/date')->date('dmy')); self::$poIsset = true; } } } return $this; } else { return parent::validate(); } }