hasShippableItems()) { $this->_initShippingTypes(); } else { /* Інакше виводимо повідомлення. */ $displayGroup = new Zend_Form_DisplayGroup( 'shippingMethods', $this->getPluginLoader(self::DECORATOR), array('form' => $this) ); $note = new Qs_Form_Element_Static( 'shippingNote', array('value' => $this->getDoc()->getSmarty()->fetch('ECommerce/Checkout/noShippingMessage.tpl')) ); $displayGroup->addElement($note); $this->_addDisplayGroupObject($displayGroup); } return $this; } protected function _initShippingTypes() { $shippingTypes = $this->getShippingType(); if (count($shippingTypes) == 1) { $shippingType = current(array_keys($shippingTypes)); $this->addElement( 'static', $shippingType . 'Title', array('value' => ucfirst(current($shippingTypes))) ); $this->addElement('hidden', 'type', array('value' => $shippingType, 'required' => true)); $this->addDisplayGroup(array('type'), 'typeGroup'); $this->_addServiceType('shipping', $shippingType); } else { foreach ($shippingTypes as $key => &$title) { $title = '' . htmlspecialchars($title) . ''; } $this->addElement('radio', 'type', array('multiOptions' => $shippingTypes, 'required' => true)); $this->getElement('type')->setAttrib('escape', false); $this->addDisplayGroup(array('type'), 'typeGroup'); foreach (array_keys($shippingTypes) as $type) { $this->_addServiceType('shipping', $type, array('class' => 'shipping')); } } $this->addElement('static', 'rate', array('label' => 'Shipping Rate:')); $this->addDisplayGroup(array('rate'), 'rateGroup'); $this->getDisplayGroup('rateGroup')->getDecorator('DtDdWrapper')->setDdAttrib('class', 'price'); $shippingData = $this->_getData('serviceShipping'); if (null !== $shippingData && array_key_exists('type', $shippingData)) { if ($this->getElement($shippingData['type'] . 'Method')) { $this->getElement($shippingData['type'] . 'Method')->setRequired(); } if (null !== ($group = $this->getDisplayGroup($shippingData['type'] . 'Methods'))) { $group->setAttrib('class', 'shipping'); } } return $this; } /** * Return type for shipping * * @return array|bool */ public function getShippingType() { $types = false; foreach ($this->_getConfig('shipping') 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('serviceShipping', $data) && array_key_exists('type', $data['serviceShipping'])) { if (null !== ($group = $this->getDisplayGroup($data['serviceShipping']['type'] . 'Methods'))) { $group->setAttrib('class', 'shipping'); } } return $this; } }