Mage_SalesRule_Model_Rule_Condition_Address Class Reference

Inheritance diagram for Mage_SalesRule_Model_Rule_Condition_Address:

Mage_Rule_Model_Condition_Abstract Varien_Object Mage_Rule_Model_Condition_Interface

List of all members.

Public Member Functions

 loadAttributeOptions ()
 getAttributeElement ()
 getInputType ()
 getValueElementType ()
 getValueSelectOptions ()
 validate (Varien_Object $object)


Detailed Description

Definition at line 28 of file Address.php.


Member Function Documentation

getAttributeElement (  ) 

Reimplemented from Mage_Rule_Model_Condition_Abstract.

Definition at line 49 of file Address.php.

00050     {
00051         $element = parent::getAttributeElement();
00052         $element->setShowAsText(true);
00053         return $element;
00054     }

getInputType (  ) 

This value will define which operators will be available for this condition.

Possible values are: string, numeric, date, select, multiselect, grid

Returns:
string

Reimplemented from Mage_Rule_Model_Condition_Abstract.

Definition at line 56 of file Address.php.

00057     {
00058         switch ($this->getAttribute()) {
00059             case 'base_subtotal': case 'weight': case 'total_qty':
00060                 return 'numeric';
00061 
00062             case 'shipping_method': case 'payment_method': case 'country_id': case 'region_id':
00063                 return 'select';
00064         }
00065         return 'string';
00066     }

getValueElementType (  ) 

Value element type will define renderer for condition value element

See also:
Varien_Data_Form_Element
Returns:
string

Reimplemented from Mage_Rule_Model_Condition_Abstract.

Definition at line 68 of file Address.php.

00069     {
00070         switch ($this->getAttribute()) {
00071             case 'shipping_method': case 'payment_method': case 'country_id': case 'region_id':
00072                 return 'select';
00073         }
00074         return 'text';
00075     }

getValueSelectOptions (  ) 

Reimplemented from Mage_Rule_Model_Condition_Abstract.

Definition at line 77 of file Address.php.

00078     {
00079         if (!$this->hasData('value_select_options')) {
00080             switch ($this->getAttribute()) {
00081                 case 'country_id':
00082                     $options = Mage::getModel('adminhtml/system_config_source_country')
00083                         ->toOptionArray();
00084                     break;
00085 
00086                 case 'region_id':
00087                     $options = Mage::getModel('adminhtml/system_config_source_allregion')
00088                         ->toOptionArray();
00089                     break;
00090 
00091                 case 'shipping_method':
00092                     $options = Mage::getModel('adminhtml/system_config_source_shipping_allmethods')
00093                         ->toOptionArray();
00094                     break;
00095 
00096                 case 'payment_method':
00097                     $options = Mage::getModel('adminhtml/system_config_source_payment_allmethods')
00098                         ->toOptionArray();
00099                     break;
00100 
00101                 default:
00102                     $options = array();
00103             }
00104             $this->setData('value_select_options', $options);
00105         }
00106         return $this->getData('value_select_options');
00107     }

loadAttributeOptions (  ) 

Reimplemented from Mage_Rule_Model_Condition_Abstract.

Definition at line 30 of file Address.php.

00031     {
00032         $attributes = array(
00033             'base_subtotal' => Mage::helper('salesrule')->__('Subtotal'),
00034             'total_qty' => Mage::helper('salesrule')->__('Total Items Quantity'),
00035             'weight' => Mage::helper('salesrule')->__('Total Weight'),
00036             'payment_method' => Mage::helper('salesrule')->__('Payment Method'),
00037             'shipping_method' => Mage::helper('salesrule')->__('Shipping Method'),
00038             'postcode' => Mage::helper('salesrule')->__('Shipping Postcode'),
00039             'region' => Mage::helper('salesrule')->__('Shipping Region'),
00040             'region_id' => Mage::helper('salesrule')->__('Shipping State/Province'),
00041             'country_id' => Mage::helper('salesrule')->__('Shipping Country'),
00042         );
00043 
00044         $this->setAttributeOption($attributes);
00045 
00046         return $this;
00047     }

validate ( Varien_Object object  ) 

Validate Address Rule Condition

Parameters:
Varien_Object $object
Returns:
bool

Reimplemented from Mage_Rule_Model_Condition_Abstract.

Definition at line 115 of file Address.php.

00116     {
00117         $address = $object;
00118         if (!$address instanceof Mage_Sales_Model_Quote_Address) {
00119             if ($object->getQuote()->isVirtual()) {
00120                 $address = $object->getQuote()->getBillingAddress();
00121             }
00122             else {
00123                 $address = $object->getQuote()->getShippingAddress();
00124             }
00125         }
00126         return parent::validate($address);
00127     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:50 2009 for Magento by  doxygen 1.5.8