当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Customer_Model_Address_Abstract::setAddressNotified方法代码示例

本文整理汇总了PHP中Mage_Customer_Model_Address_Abstract::setAddressNotified方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Customer_Model_Address_Abstract::setAddressNotified方法的具体用法?PHP Mage_Customer_Model_Address_Abstract::setAddressNotified怎么用?PHP Mage_Customer_Model_Address_Abstract::setAddressNotified使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Customer_Model_Address_Abstract的用法示例。


在下文中一共展示了Mage_Customer_Model_Address_Abstract::setAddressNotified方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _addressValidation

 /**
  * Address validation
  *
  * @param int $isAddressValidationOn
  * @param int $isAddressActionable
  * @param ValidateResult $result
  * @return array|bool|null
  */
 protected function _addressValidation($isAddressValidationOn, $isAddressActionable, $result)
 {
     if ($isAddressValidationOn == OnePica_AvaTax_Model_Source_Addressvalidation::ENABLED_PREVENT_ORDER) {
         if ($result->getResultCode() == SeverityLevel::$Success) {
             $this->_mageAddress->setAddressValidated(true);
             return true;
         } else {
             $errors = array();
             foreach ($result->getMessages() as $message) {
                 $errors[] = $this->__($message->getSummary());
             }
             return $errors;
         }
     } elseif ($isAddressValidationOn == OnePica_AvaTax_Model_Source_Addressvalidation::ENABLED_ALLOW_ORDER) {
         $this->_mageAddress->setAddressValidated(true);
         if ($result->getResultCode() == SeverityLevel::$Success) {
             return true;
         } else {
             if (!$this->_mageAddress->getAddressNotified()) {
                 $this->_mageAddress->setAddressNotified(true);
                 foreach ($result->getMessages() as $message) {
                     Mage::getSingleton('core/session')->addNotice($this->__($message->getSummary()));
                 }
             }
             return true;
         }
         //a valid address isn't required, but Avalara has to say there is
         //enough info to drill down to a tax jurisdiction to calc on
     } elseif (!$isAddressValidationOn && $isAddressActionable) {
         if ($result->isTaxable()) {
             $this->_mageAddress->setAddressValidated(true);
             return true;
         } else {
             $errors = array();
             foreach ($result->getMessages() as $message) {
                 $errors[] = $this->__($message->getSummary());
             }
             return $errors;
         }
     }
     return null;
 }
开发者ID:sojimaxi,项目名称:avatax,代码行数:50,代码来源:Address.php

示例2: validate

 /**
  * Validates the address with the AvaTax validation API.
  * Returns true on success and an array with an error on failure.
  *
  * @return array|bool
  * @throws OnePica_AvaTax_Model_Avatax_Address_Exception
  */
 public function validate()
 {
     if (!$this->_mageAddress) {
         throw new OnePica_AvaTax_Model_Avatax_Address_Exception($this->__('An address must be set before validation.'));
     }
     /** @var OnePica_AvaTax_Model_Config $config */
     $config = Mage::getSingleton('avatax/config')->init($this->_storeId);
     /** @var Mage_Sales_Model_Quote $quote */
     $quote = $this->_mageAddress->getQuote();
     $isAddressValidationOn = $this->_getDataHelper()->isAddressValidationOn($this->_mageAddress, $this->_storeId);
     $isAddressNormalizationOn = $this->_getDataHelper()->isAddressNormalizationOn($this->_mageAddress, $this->_storeId);
     $isAddressActionable = $this->_getDataHelper()->isAddressActionable($this->_mageAddress, $quote->getStoreId());
     //if there is no use cases for AvaTax services, return address as valid without doing a lookup
     if (!$isAddressValidationOn && !$isAddressNormalizationOn && !$isAddressActionable) {
         return true;
     }
     //lookup in AvaTax (with caching)
     $key = $this->_mageAddress->getCacheHashKey();
     if (array_key_exists($key, $this->_cache)) {
         $result = unserialize($this->_cache[$key]);
     } elseif ($this->_mageAddress->getPostcode() && $this->_mageAddress->getPostcode() != '-') {
         $session = Mage::getSingleton('checkout/session');
         if ($session->getPostType() == 'onepage') {
             $requiredFields = explode(",", $this->getHelper()->getFieldRequiredList());
             $fieldRules = explode(",", $this->getHelper()->getFieldRule());
             foreach ($requiredFields as $field) {
                 $requiredFlag = 0;
                 foreach ($fieldRules as $rule) {
                     if (preg_match("/street\\d/", $field)) {
                         $field = "street";
                     }
                     if ($field == "country") {
                         $field = "country_id";
                     }
                     if ($this->_mageAddress->getData($field) == $rule || !$this->_mageAddress->getData($field)) {
                         $requiredFlag = 1;
                     }
                 }
                 if ($requiredFlag) {
                     $errors = array();
                     $errors[] = $this->__('Invalid ') . $this->__($field);
                     return $errors;
                 }
             }
         }
         $client = $config->getAddressConnection();
         $request = new ValidateRequest($this->_requestAddress, TextCase::$Mixed, 0);
         $request->setTaxability(true);
         $result = $client->Validate($request);
         $this->_log(OnePica_AvaTax_Model_Source_Logtype::VALIDATE, $request, $result, $this->_storeId, $config->getParams());
         $this->_cache[$key] = serialize($result);
     } else {
         $errors = array();
         $errors[] = $this->__('Invalid ZIP/Postal Code.');
         return $errors;
     }
     //normalization
     if ($isAddressNormalizationOn && $result->getResultCode() == SeverityLevel::$Success) {
         $responseAddress = $result->getValidAddresses();
         $responseAddress = array_pop($responseAddress);
         if ($responseAddress instanceof ValidAddress) {
             $this->_responseAddress = $responseAddress;
             $this->_convertResponseAddress();
         } else {
             throw new OnePica_AvaTax_Model_Avatax_Address_Exception($this->__('Invalid response address type.'));
         }
     }
     //validation
     if ($isAddressValidationOn == 1) {
         if ($result->getResultCode() == SeverityLevel::$Success) {
             $this->_mageAddress->setAddressValidated(true);
             return true;
         } else {
             $errors = array();
             foreach ($result->getMessages() as $message) {
                 $errors[] = $this->__($message->getSummary());
             }
             return $errors;
         }
     } elseif ($isAddressValidationOn == 2) {
         $this->_mageAddress->setAddressValidated(true);
         if ($result->getResultCode() == SeverityLevel::$Success) {
             return true;
         } else {
             if (!$this->_mageAddress->getAddressNotified()) {
                 $this->_mageAddress->setAddressNotified(true);
                 foreach ($result->getMessages() as $message) {
                     Mage::getSingleton('core/session')->addNotice($this->__($message->getSummary()));
                 }
             }
             return true;
         }
         //a valid address isn't required, but Avalara has to say there is
//.........这里部分代码省略.........
开发者ID:boostmagento,项目名称:avatax,代码行数:101,代码来源:Address.php


注:本文中的Mage_Customer_Model_Address_Abstract::setAddressNotified方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。