當前位置: 首頁>>代碼示例>>PHP>>正文


PHP State::Load方法代碼示例

本文整理匯總了PHP中State::Load方法的典型用法代碼示例。如果您正苦於以下問題:PHP State::Load方法的具體用法?PHP State::Load怎麽用?PHP State::Load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在State的用法示例。


在下文中一共展示了State::Load方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: validateAttribute

 /**
  * Validates that the state that the customer enters either
  * in the shipping form or billing form respects the format
  * for the countries we want to validate it upon.
  *
  * @param CModel $model
  * @param string $attribute
  * @return void
  */
 public function validateAttribute($model, $attribute)
 {
     switch ($attribute) {
         case 'shippingState':
             $objCountry = Country::Load($model->shippingCountry);
             break;
         case 'billingState':
             $objCountry = Country::Load($model->billingCountry);
             break;
         default:
             // Cannot validate any other attributes.
             return;
     }
     if ($objCountry === null) {
         // Country isn't valid, can't validate the state!
         return;
     }
     $countriesToValidateState = array(self::USA, self::CANADA, self::AUSTRALIA);
     if (in_array($objCountry->id, $countriesToValidateState) === false) {
         // Do not attempt to validate the state.
         return;
     }
     if (empty($model->{$attribute}) === true) {
         $this->addError($model, $attribute, Yii::t('yii', '{attributeName} cannot be blank.', array('{attributeName}' => $model->getattributeLabel($attribute))));
     } else {
         $objState = State::Load($model->{$attribute});
         if ($objState === null) {
             $this->addError($model, $attribute, Yii::t('yii', '{attributeName} is invalid.', array('{attributeName}' => $model->getattributeLabel($attribute))));
         }
     }
 }
開發者ID:uiDeveloper116,項目名稱:webstore,代碼行數:40,代碼來源:StateValidator.php

示例2: setBillingState

 public function setBillingState($intState)
 {
     $objBillingState = State::Load($intState);
     if ($objBillingState !== null) {
         $this->billingStateCode = $objBillingState->code;
         $this->billingCountry = $objBillingState->country_id;
     }
 }
開發者ID:uiDeveloper116,項目名稱:webstore,代碼行數:8,代碼來源:BaseCheckoutForm.php

示例3: actionSetTaxByAddress

 /**
  * Set the cart tax code based on an address.
  * The country_id parameter is required, state_id and postal are optional.
  */
 public function actionSetTaxByAddress()
 {
     $intCountryId = Yii::app()->getRequest()->getParam('country_id');
     $intStateId = Yii::app()->getRequest()->getParam('state_id', '');
     $strPostal = Yii::app()->getRequest()->getParam('postal', '');
     $objCountry = Country::Load($intCountryId);
     if ($objCountry === null) {
         throw new CHttpException(400, Yii::t('application errors', 'Invalid country_id.'));
     }
     $strStateCode = null;
     if ($intStateId !== '') {
         $objState = State::Load($intStateId);
         if ($objState === null) {
             throw new CHttpException(400, Yii::t('application errors', 'Invalid state_id.'));
         }
         // Validate the state/country combination.
         $arrShippingStates = Country::getCountryShippingStates($intCountryId);
         if (array_key_exists($intStateId, $arrShippingStates) === false) {
             throw new CHttpException(400, Yii::t('application errors', 'The state_id is not valid for the country_id.'));
         }
         $strStateCode = $objState->code;
     }
     Yii::app()->shoppingcart->setTaxCodeByAddress($objCountry->code, $strStateCode, $strPostal);
     $arrReturn['cartitems'] = $this->renderPartial('/cart/_cartitems', null, true);
     if (Yii::app()->session->get('ship.prices.cache', null) !== null) {
         $arrReturn['action'] = 'triggerCalc';
     }
     return $this->renderJSON($arrReturn);
 }
開發者ID:uiDeveloper116,項目名稱:webstore,代碼行數:33,代碼來源:CartController.php


注:本文中的State::Load方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。