Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_GoogleCheckout_ApiController
  • Mage_GoogleCheckout_Block_Adminhtml_Shipping_Applicable_Countries
  • Mage_GoogleCheckout_Block_Adminhtml_Shipping_Merchant
  • Mage_GoogleCheckout_Block_Form
  • Mage_GoogleCheckout_Block_Link
  • Mage_GoogleCheckout_Block_Redirect
  • Mage_GoogleCheckout_Helper_Data
  • Mage_GoogleCheckout_Model_Api
  • Mage_GoogleCheckout_Model_Api_Debug
  • Mage_GoogleCheckout_Model_Api_Xml_Abstract
  • Mage_GoogleCheckout_Model_Api_Xml_Calculate
  • Mage_GoogleCheckout_Model_Api_Xml_Callback
  • Mage_GoogleCheckout_Model_Api_Xml_Checkout
  • Mage_GoogleCheckout_Model_Api_Xml_Order
  • Mage_GoogleCheckout_Model_Mysql4_Api_Debug
  • Mage_GoogleCheckout_Model_Mysql4_Api_Debug_Collection
  • Mage_GoogleCheckout_Model_Mysql4_Notification
  • Mage_GoogleCheckout_Model_Mysql4_Setup
  • Mage_GoogleCheckout_Model_Mysql4_Tax
  • Mage_GoogleCheckout_Model_Notification
  • Mage_GoogleCheckout_Model_Observer
  • Mage_GoogleCheckout_Model_Payment
  • Mage_GoogleCheckout_Model_Resource_Api_Debug
  • Mage_GoogleCheckout_Model_Resource_Api_Debug_Collection
  • Mage_GoogleCheckout_Model_Resource_Notification
  • Mage_GoogleCheckout_Model_Resource_Setup
  • Mage_GoogleCheckout_Model_Resource_Tax
  • Mage_GoogleCheckout_Model_Shipping
  • Mage_GoogleCheckout_Model_Source_Checkout_Image
  • Mage_GoogleCheckout_Model_Source_Locale
  • Mage_GoogleCheckout_Model_Source_Shipping_Carrier
  • Mage_GoogleCheckout_Model_Source_Shipping_Category
  • Mage_GoogleCheckout_Model_Source_Shipping_Units
  • Mage_GoogleCheckout_Model_Source_Shipping_Virtual_Method
  • Mage_GoogleCheckout_Model_Source_Shipping_Virtual_Schedule
  • Mage_GoogleCheckout_RedirectController

Exceptions

  • Mage_GoogleCheckout_Exception
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_GoogleCheckout
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: class Mage_GoogleCheckout_Block_Adminhtml_Shipping_Merchant
 28:     extends Mage_Adminhtml_Block_System_Config_Form_Field
 29: {
 30:     protected $_addRowButtonHtml = array();
 31:     protected $_removeRowButtonHtml = array();
 32: 
 33:     protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 34:     {
 35:         $this->setElement($element);
 36: 
 37:         $html = '<div id="merchant_allowed_methods_template" style="display:none">';
 38:         $html .= $this->_getRowTemplateHtml();
 39:         $html .= '</div>';
 40: 
 41:         $html .= '<ul id="merchant_allowed_methods_container">';
 42:         if ($this->_getValue('method')) {
 43:             foreach ($this->_getValue('method') as $i => $f) {
 44:                 if ($i) {
 45:                     $html .= $this->_getRowTemplateHtml($i);
 46:                 }
 47:             }
 48:         }
 49:         $html .= '</ul>';
 50:         $html .= $this->_getAddRowButtonHtml('merchant_allowed_methods_container',
 51:             'merchant_allowed_methods_template', $this->__('Add Shipping Method'));
 52: 
 53:         return $html;
 54:     }
 55: 
 56:     /**
 57:      * Retrieve html template for shipping method row
 58:      *
 59:      * @param int $rowIndex
 60:      * @return string
 61:      */
 62:     protected function _getRowTemplateHtml($rowIndex = 0)
 63:     {
 64:         $html = '<li>';
 65:         $html .= '<select name="' . $this->getElement()->getName() . '[method][]" ' . $this->_getDisabled() . '>';
 66:         $html .= '<option value="">' . $this->__('* Select shipping method') . '</option>';
 67: 
 68:         foreach ($this->getShippingMethods() as $carrierCode => $carrier) {
 69:             $html .= '<optgroup label="' . $this->escapeHtml($carrier['title'])
 70:                 . '" style="border-top:solid 1px black; margin-top:3px;">';
 71: 
 72:             foreach ($carrier['methods'] as $methodCode => $method) {
 73:                 $code = $carrierCode . '/' . $methodCode;
 74:                 $html .= '<option value="' . $this->escapeHtml($code) . '" '
 75:                     . $this->_getSelected('method/' . $rowIndex, $code)
 76:                     . ' style="background:white;">' . $this->escapeHtml($method['title']) . '</option>';
 77:             }
 78:             $html .= '</optgroup>';
 79:         }
 80:         $html .= '</select>';
 81: 
 82:         $html .= '<div style="margin:5px 0 10px;">';
 83:         $html .= '<label>' . $this->__('Default price:') . '</label> ';
 84:         $html .= '<input class="input-text" style="width:70px;" name="'
 85:             . $this->getElement()->getName() . '[price][]" value="'
 86:             . $this->_getValue('price/' . $rowIndex) . '" ' . $this->_getDisabled() . '/> ';
 87: 
 88:         $html .= $this->_getRemoveRowButtonHtml();
 89:         $html .= '</div>';
 90:         $html .= '</li>';
 91: 
 92:         return $html;
 93:     }
 94: 
 95:     protected function getShippingMethods()
 96:     {
 97:         if (!$this->hasData('shipping_methods')) {
 98:             $website = $this->getRequest()->getParam('website');
 99:             $store   = $this->getRequest()->getParam('store');
100: 
101:             $storeId = null;
102:             if (!is_null($website)) {
103:                 $storeId = Mage::getModel('core/website')
104:                     ->load($website, 'code')
105:                     ->getDefaultGroup()
106:                     ->getDefaultStoreId();
107:             } elseif (!is_null($store)) {
108:                 $storeId = Mage::getModel('core/store')
109:                     ->load($store, 'code')
110:                     ->getId();
111:             }
112: 
113:             $methods = array();
114:             $carriers = Mage::getSingleton('shipping/config')->getActiveCarriers($storeId);
115:             foreach ($carriers as $carrierCode=>$carrierModel) {
116:                 if (!$carrierModel->isActive()) {
117:                     continue;
118:                 }
119:                 $carrierMethods = $carrierModel->getAllowedMethods();
120:                 if (!$carrierMethods) {
121:                     continue;
122:                 }
123:                 $carrierTitle = Mage::getStoreConfig('carriers/' . $carrierCode . '/title', $storeId);
124:                 $methods[$carrierCode] = array(
125:                     'title'   => $carrierTitle,
126:                     'methods' => array(),
127:                 );
128:                 foreach ($carrierMethods as $methodCode=>$methodTitle) {
129:                     $methods[$carrierCode]['methods'][$methodCode] = array(
130:                         'title' => '[' . $carrierCode . '] ' . $methodTitle,
131:                     );
132:                 }
133:             }
134:             $this->setData('shipping_methods', $methods);
135:         }
136:         return $this->getData('shipping_methods');
137:     }
138: 
139:     protected function _getDisabled()
140:     {
141:         return $this->getElement()->getDisabled() ? ' disabled' : '';
142:     }
143: 
144:     protected function _getValue($key)
145:     {
146:         return $this->getElement()->getData('value/' . $key);
147:     }
148: 
149:     protected function _getSelected($key, $value)
150:     {
151:         return $this->getElement()->getData('value/' . $key) == $value ? 'selected="selected"' : '';
152:     }
153: 
154:     protected function _getAddRowButtonHtml($container, $template, $title='Add')
155:     {
156:         if (!isset($this->_addRowButtonHtml[$container])) {
157:             $this->_addRowButtonHtml[$container] = $this->getLayout()->createBlock('adminhtml/widget_button')
158:                     ->setType('button')
159:                     ->setClass('add ' . $this->_getDisabled())
160:                     ->setLabel($this->__($title))
161:                     ->setOnClick("Element.insert($('" . $container . "'), {bottom: $('" . $template . "').innerHTML})")
162:                     ->setDisabled($this->_getDisabled())
163:                     ->toHtml();
164:         }
165:         return $this->_addRowButtonHtml[$container];
166:     }
167: 
168:     protected function _getRemoveRowButtonHtml($selector = 'li', $title = 'Remove')
169:     {
170:         if (!$this->_removeRowButtonHtml) {
171:             $this->_removeRowButtonHtml = $this->getLayout()->createBlock('adminhtml/widget_button')
172:                     ->setType('button')
173:                     ->setClass('delete v-middle ' . $this->_getDisabled())
174:                     ->setLabel($this->__($title))
175:                     ->setOnClick("Element.remove($(this).up('" . $selector . "'))")
176:                     ->setDisabled($this->_getDisabled())
177:                     ->toHtml();
178:         }
179:         return $this->_removeRowButtonHtml;
180:     }
181: }
182: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0