setElement($element); $html = ''; $html .= ''; $html .= $this->_getAddRowButtonHtml('merchant_allowed_methods_container', 'merchant_allowed_methods_template', $this->__('Add Shipping Method')); return $html; } /** * Retrieve html template for shipping method row * * @param int $rowIndex * @return string */ protected function _getRowTemplateHtml($rowIndex = 0) { $html = '
  • '; $html .= ''; $html .= '
    '; $html .= ' '; $html .= '_getDisabled() . '/> '; $html .= $this->_getRemoveRowButtonHtml(); $html .= '
    '; $html .= '
  • '; return $html; } protected function getShippingMethods() { if (!$this->hasData('shipping_methods')) { $website = $this->getRequest()->getParam('website'); $store = $this->getRequest()->getParam('store'); $storeId = null; if (!is_null($website)) { $storeId = Mage::getModel('core/website') ->load($website, 'code') ->getDefaultGroup() ->getDefaultStoreId(); } elseif (!is_null($store)) { $storeId = Mage::getModel('core/store') ->load($store, 'code') ->getId(); } $methods = array(); $carriers = Mage::getSingleton('shipping/config')->getActiveCarriers($storeId); foreach ($carriers as $carrierCode=>$carrierModel) { if (!$carrierModel->isActive()) { continue; } $carrierMethods = $carrierModel->getAllowedMethods(); if (!$carrierMethods) { continue; } $carrierTitle = Mage::getStoreConfig('carriers/' . $carrierCode . '/title', $storeId); $methods[$carrierCode] = array( 'title' => $carrierTitle, 'methods' => array(), ); foreach ($carrierMethods as $methodCode=>$methodTitle) { $methods[$carrierCode]['methods'][$methodCode] = array( 'title' => '[' . $carrierCode . '] ' . $methodTitle, ); } } $this->setData('shipping_methods', $methods); } return $this->getData('shipping_methods'); } protected function _getDisabled() { return $this->getElement()->getDisabled() ? ' disabled' : ''; } protected function _getValue($key) { return $this->getElement()->getData('value/' . $key); } protected function _getSelected($key, $value) { return $this->getElement()->getData('value/' . $key) == $value ? 'selected="selected"' : ''; } protected function _getAddRowButtonHtml($container, $template, $title='Add') { if (!isset($this->_addRowButtonHtml[$container])) { $this->_addRowButtonHtml[$container] = $this->getLayout()->createBlock('adminhtml/widget_button') ->setType('button') ->setClass('add ' . $this->_getDisabled()) ->setLabel($this->__($title)) ->setOnClick("Element.insert($('" . $container . "'), {bottom: $('" . $template . "').innerHTML})") ->setDisabled($this->_getDisabled()) ->toHtml(); } return $this->_addRowButtonHtml[$container]; } protected function _getRemoveRowButtonHtml($selector = 'li', $title = 'Remove') { if (!$this->_removeRowButtonHtml) { $this->_removeRowButtonHtml = $this->getLayout()->createBlock('adminhtml/widget_button') ->setType('button') ->setClass('delete v-middle ' . $this->_getDisabled()) ->setLabel($this->__($title)) ->setOnClick("Element.remove($(this).up('" . $selector . "'))") ->setDisabled($this->_getDisabled()) ->toHtml(); } return $this->_removeRowButtonHtml; } }