/** * Validate Address Rule Condition * * @param Varien_Object|Mage_Sales_Model_Order|Mage_Sales_Model_Quote $object * @return bool */ public function validate(Varien_Object $object) { $quote = $object; if (!$object instanceof Mage_Sales_Model_Quote) { $quote = Mage::getModel('sales/quote')->load($object->getQuoteId()); } $address = $quote->getBillingAddress(); //Get infos from billing address $toValidate = new Varien_Object(); $toValidate->setBillingPostcode($address->getPostcode()); $toValidate->setBillingRegion($address->getRegion()); $toValidate->setBillingRegionId($address->getRegionId()); $toValidate->setBillingCountryId($address->getCountryId()); if (!$quote->isVirtual()) { //Get infos from shipping address $address = $quote->getShippingAddress(); } $toValidate->setBaseSubtotal($address->getBaseSubtotal()); $toValidate->setBaseGrandTotal($address->getBaseGrandTotal()); $toValidate->setWeight($address->getWeight()); $toValidate->setShippingMethod($address->getShippingMethod()); $toValidate->setTotalQty($quote->getItemsQty()); $toValidate->setBaseCurrencyCode($quote->getBaseCurrencyCode()); $toValidate->setCreatedAt($this->_getFormatCreatedAt($object)); return parent::validate($toValidate); }