_isSponsorAtCart = $isSponsorAtCart; return $this; } public function setPaymentTypes($paymentTypes) { $this->_paymentTypes = $paymentTypes; return $this; } protected function _initElements() { $paymentTypes = $this->getPaymentType(); if ($this->_isSponsorAtCart && isset($paymentTypes[\App_ECommerce_Order_Abstract_Obj::PAYMENT_TYPE_PAY_LATER])) { unset($paymentTypes[\App_ECommerce_Order_Abstract_Obj::PAYMENT_TYPE_PAY_LATER]); } if (count($paymentTypes) == 1) { $paymentType = current(array_keys($paymentTypes)); $paymentTitle = ucfirst(current($paymentTypes)); $this->addElement('static', $paymentType . 'Title', array('value' => $paymentTitle)); $this->addElement('hidden', 'type', array('value' => $paymentType, 'required' => true)); $this->addDisplayGroup(array('type'), 'typeGroup'); $this->_addServiceType('payment', $paymentType); } else { $options = array( 'multiOptions' => $paymentTypes, 'required' => true, 'columns' => count($paymentTypes), ); $this->addElement('radio', 'type', $options); $this->addDisplayGroup(array('type'), 'typeGroup'); foreach (array_keys($paymentTypes) as $type) { $this->_addServiceType('payment', $type, array('class' => 'payment hidden')); } } if (($paymentData = $this->_getData('servicePayment')) !== null) { foreach (array_keys($paymentTypes) as $type) { if (array_key_exists('type', $paymentData) && $paymentData['type'] == $type) { if (null !== ($group = $this->getDisplayGroup($type . 'Methods'))) { $group->setAttrib('class', 'payment'); } continue; } if (null !== ($group = $this->getDisplayGroup($type . 'Methods'))) { foreach ($group->getElements() as $element) { /** @var $element Zend_Form_Element */ $element->setRequired(false); } } } } return $this; } /** * Return type for payment * * @return array|bool */ public function getPaymentType() { $types = false; $list = $this->_paymentTypes ? $this->_paymentTypes : $this->_getConfig('payment'); foreach ($list as $key => $type) { if (is_int($key)) { $title = ucfirst($type); } else { $title = $type; $type = $key; } $types[$type] = $title; } return $types; } public function reinitData($data) { if (array_key_exists('servicePayment', $data) && array_key_exists('type', $data['servicePayment'])) { if (null !== ($group = $this->getDisplayGroup($data['servicePayment']['type'] . 'Methods'))) { $group->setAttrib('class', 'payment'); } } return $this; } }