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_SalesRule_Exception
  • Mage_SalesRule_Helper_Coupon
  • Mage_SalesRule_Helper_Data
  • Mage_SalesRule_Model_Coupon
  • Mage_SalesRule_Model_Coupon_Codegenerator
  • Mage_SalesRule_Model_Coupon_Massgenerator
  • Mage_SalesRule_Model_Mysql4_Coupon
  • Mage_SalesRule_Model_Mysql4_Coupon_Collection
  • Mage_SalesRule_Model_Mysql4_Coupon_Usage
  • Mage_SalesRule_Model_Mysql4_Report_Collection
  • Mage_SalesRule_Model_Mysql4_Report_Rule
  • Mage_SalesRule_Model_Mysql4_Report_Updatedat_Collection
  • Mage_SalesRule_Model_Mysql4_Rule
  • Mage_SalesRule_Model_Mysql4_Rule_Collection
  • Mage_SalesRule_Model_Mysql4_Rule_Customer
  • Mage_SalesRule_Model_Mysql4_Rule_Customer_Collection
  • Mage_SalesRule_Model_Mysql4_Rule_Product
  • Mage_SalesRule_Model_Mysql4_Rule_Product_Collection
  • Mage_SalesRule_Model_Observer
  • Mage_SalesRule_Model_Quote_Discount
  • Mage_SalesRule_Model_Quote_Freeshipping
  • Mage_SalesRule_Model_Quote_Nominal_Discount
  • Mage_SalesRule_Model_Resource_Coupon
  • Mage_SalesRule_Model_Resource_Coupon_Collection
  • Mage_SalesRule_Model_Resource_Coupon_Usage
  • Mage_SalesRule_Model_Resource_Report_Collection
  • Mage_SalesRule_Model_Resource_Report_Rule
  • Mage_SalesRule_Model_Resource_Report_Rule_Createdat
  • Mage_SalesRule_Model_Resource_Report_Rule_Updatedat
  • Mage_SalesRule_Model_Resource_Report_Updatedat_Collection
  • Mage_SalesRule_Model_Resource_Rule
  • Mage_SalesRule_Model_Resource_Rule_Collection
  • Mage_SalesRule_Model_Resource_Rule_Customer
  • Mage_SalesRule_Model_Resource_Rule_Customer_Collection
  • Mage_SalesRule_Model_Resource_Rule_Product
  • Mage_SalesRule_Model_Resource_Rule_Product_Collection
  • Mage_SalesRule_Model_Rule
  • Mage_SalesRule_Model_Rule_Action_Collection
  • Mage_SalesRule_Model_Rule_Action_Product
  • Mage_SalesRule_Model_Rule_Condition_Address
  • Mage_SalesRule_Model_Rule_Condition_Combine
  • Mage_SalesRule_Model_Rule_Condition_Product
  • Mage_SalesRule_Model_Rule_Condition_Product_Combine
  • Mage_SalesRule_Model_Rule_Condition_Product_Found
  • Mage_SalesRule_Model_Rule_Condition_Product_Subselect
  • Mage_SalesRule_Model_Rule_Customer
  • Mage_SalesRule_Model_Rule_Product
  • Mage_SalesRule_Model_System_Config_Source_Coupon_Format
  • Mage_SalesRule_Model_Validator

Interfaces

  • Mage_SalesRule_Model_Coupon_CodegeneratorInterface
  • 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_SalesRule
 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: 
 28: class Mage_SalesRule_Model_Rule_Condition_Address extends Mage_Rule_Model_Condition_Abstract
 29: {
 30:     public function loadAttributeOptions()
 31:     {
 32:         $attributes = array(
 33:             'base_subtotal' => Mage::helper('salesrule')->__('Subtotal'),
 34:             'total_qty' => Mage::helper('salesrule')->__('Total Items Quantity'),
 35:             'weight' => Mage::helper('salesrule')->__('Total Weight'),
 36:             'payment_method' => Mage::helper('salesrule')->__('Payment Method'),
 37:             'shipping_method' => Mage::helper('salesrule')->__('Shipping Method'),
 38:             'postcode' => Mage::helper('salesrule')->__('Shipping Postcode'),
 39:             'region' => Mage::helper('salesrule')->__('Shipping Region'),
 40:             'region_id' => Mage::helper('salesrule')->__('Shipping State/Province'),
 41:             'country_id' => Mage::helper('salesrule')->__('Shipping Country'),
 42:         );
 43: 
 44:         $this->setAttributeOption($attributes);
 45: 
 46:         return $this;
 47:     }
 48: 
 49:     public function getAttributeElement()
 50:     {
 51:         $element = parent::getAttributeElement();
 52:         $element->setShowAsText(true);
 53:         return $element;
 54:     }
 55: 
 56:     public function getInputType()
 57:     {
 58:         switch ($this->getAttribute()) {
 59:             case 'base_subtotal': case 'weight': case 'total_qty':
 60:                 return 'numeric';
 61: 
 62:             case 'shipping_method': case 'payment_method': case 'country_id': case 'region_id':
 63:                 return 'select';
 64:         }
 65:         return 'string';
 66:     }
 67: 
 68:     public function getValueElementType()
 69:     {
 70:         switch ($this->getAttribute()) {
 71:             case 'shipping_method': case 'payment_method': case 'country_id': case 'region_id':
 72:                 return 'select';
 73:         }
 74:         return 'text';
 75:     }
 76: 
 77:     public function getValueSelectOptions()
 78:     {
 79:         if (!$this->hasData('value_select_options')) {
 80:             switch ($this->getAttribute()) {
 81:                 case 'country_id':
 82:                     $options = Mage::getModel('adminhtml/system_config_source_country')
 83:                         ->toOptionArray();
 84:                     break;
 85: 
 86:                 case 'region_id':
 87:                     $options = Mage::getModel('adminhtml/system_config_source_allregion')
 88:                         ->toOptionArray();
 89:                     break;
 90: 
 91:                 case 'shipping_method':
 92:                     $options = Mage::getModel('adminhtml/system_config_source_shipping_allmethods')
 93:                         ->toOptionArray();
 94:                     break;
 95: 
 96:                 case 'payment_method':
 97:                     $options = Mage::getModel('adminhtml/system_config_source_payment_allmethods')
 98:                         ->toOptionArray();
 99:                     break;
100: 
101:                 default:
102:                     $options = array();
103:             }
104:             $this->setData('value_select_options', $options);
105:         }
106:         return $this->getData('value_select_options');
107:     }
108: 
109:     /**
110:      * Validate Address Rule Condition
111:      *
112:      * @param Varien_Object $object
113:      * @return bool
114:      */
115:     public function validate(Varien_Object $object)
116:     {
117:         $address = $object;
118:         if (!$address instanceof Mage_Sales_Model_Quote_Address) {
119:             if ($object->getQuote()->isVirtual()) {
120:                 $address = $object->getQuote()->getBillingAddress();
121:             }
122:             else {
123:                 $address = $object->getQuote()->getShippingAddress();
124:             }
125:         }
126: 
127:         if ('payment_method' == $this->getAttribute() && ! $address->hasPaymentMethod()) {
128:             $address->setPaymentMethod($object->getQuote()->getPayment()->getMethod());
129:         }
130: 
131:         return parent::validate($address);
132:     }
133: }
134: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0