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


PHP State::CodeById方法代码示例

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


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

示例1: run

 public function run()
 {
     $unit = 1;
     $country = $this->CheckoutForm->shippingCountryCode;
     $state = $this->CheckoutForm->shippingStateCode;
     $zipcode = $this->CheckoutForm->shippingPostal;
     // We can't do a lookup if the country is blank
     if (empty($country)) {
         Yii::log('DESTINATION TABLE: insufficient details for destination shipping. Shipping Country is blank.', 'info', 'application.' . __CLASS__ . '.' . __FUNCTION__);
         return false;
     }
     Yii::log("DESTINATION TABLE: searching for {$country}/{$state}/{$zipcode}", 'info', 'application.' . __CLASS__ . "." . __FUNCTION__);
     if (!isset($this->config['per'])) {
         Yii::log("DESTINATION TABLE: could not get destination shipping unit.", 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
         return false;
     }
     // Get the best matching destination
     $model = Destination::LoadMatching($country, $state, $zipcode);
     if ($model === null) {
         Yii::log("DESTINATION TABLE: No matching entry found for {$country} {$state} {$zipcode} .", 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
         return false;
     }
     if ($this->config['per'] == 'item') {
         $unit = $this->objCart->TotalItemCount;
     } elseif ($this->config['per'] == 'weight') {
         $unit = $this->objCart->Weight;
     } elseif ($this->config['per'] == 'volume') {
         $unit = $this->objCart->Length * $this->objCart->Width * $this->objCart->Height;
     }
     if ($unit >= $model->ship_free) {
         $unit -= $model->ship_free;
     }
     if ($unit < 0) {
         $unit = 0;
     }
     // If the Base Charge is unset or lesser than 0, don't apply this module
     if ($model->base_charge == '' || $model->base_charge == null) {
         $label = Country::CodeById($model->country) . "/" . State::CodeById($model->state);
         Yii::log("DESTINATION TABLE: Base charge not set for entry '" . $label . "'", 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
         return false;
     }
     $desc = isset($this->config['offerservices']) ? $this->config['offerservices'] : Yii::t('global', 'Standard 3-5 Business Days');
     $ret[$desc] = $model->base_charge + $unit * $model->ship_rate;
     return $this->convertRetToDisplay($ret);
 }
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:45,代码来源:destinationshipping.php

示例2: total

 /**
  * Based on passed address information, calculates the total shipping cost
  *
  * @param $fields
  * @param $cart
  * @param string $country
  * @param string $zipcode
  * @param string $state
  * @param string $city
  * @param string $address2
  * @param string $address1
  * @param string $company
  * @param string $lname
  * @param string $fname
  * @return array|bool
  */
 public function total($fields, $cart, $country = '', $zipcode = '', $state = '', $city = '', $address2 = '', $address1 = '', $company = '', $lname = '', $fname = '')
 {
     $config = $this->getConfigValues(get_class($this));
     $weight = $cart->Weight;
     if (_xls_get_conf('WEIGHT_UNIT', 'lb') != 'lb') {
         $weight = $weight * 2.2;
     }
     // one KG is 2.2 pounds
     $length = $cart->Length;
     $width = $cart->Width;
     $height = $cart->Height;
     if (_xls_get_conf('DIMENSION_UNIT', 'in') != 'in') {
         $length = round($length / 2.54);
         $width = round($width / 2.54);
         $height = round($height / 2.54);
     }
     if ($length < 1 && $length > 0) {
         $length = 1;
     }
     if ($width < 1 && $width > 0) {
         $width = 1;
     }
     if ($height < 1 && $height > 0) {
         $height = 1;
     }
     if (empty($config['securitycode']) || empty($config['accnumber']) || empty($config['meternumber'])) {
         return FALSE;
     }
     $ret = array();
     $newline = "<br />";
     //The WSDL is not included with the sample code.
     //Please include and reference in $path_to_wsdl variable.
     $path_to_wsdl = dirname(__FILE__) . "/RateService_v7.wsdl";
     ini_set("soap.wsdl_cache_enabled", "0");
     $client = new SoapClient($path_to_wsdl, array('trace' => 1));
     $request['WebAuthenticationDetail'] = array('UserCredential' => array('Key' => $config['authkey'], 'Password' => $config['securitycode']));
     $request['ClientDetail'] = array('AccountNumber' => $config['accnumber'], 'MeterNumber' => $config['meternumber']);
     $request['TransactionDetail'] = array('CustomerTransactionId' => ' *** Rate Request v7 using PHP ***');
     $request['Version'] = array('ServiceId' => 'crs', 'Major' => '7', 'Intermediate' => '0', 'Minor' => '0');
     $request['ReturnTransitAndCommit'] = true;
     $request['RequestedShipment']['DropoffType'] = 'REGULAR_PICKUP';
     // valid values REGULAR_PICKUP, REQUEST_COURIER, ...
     $request['RequestedShipment']['ShipTimestamp'] = date('c');
     //Uncomment these additional options below if they are needed for your shipments
     //$request['RequestedShipment']['SpecialServicesRequested'] = array( 'SpecialServiceTypes' => array('SIGNATURE_OPTION'), 'SignatureOptionDetail' => array('OptionType' => 'ADULT'));
     //$request['RequestedShipment']['SignatureOptionDetail']['OptionType'] = 'ADULT';
     //$request['RequestedShipment']['ServiceType'] = 'PRIORITY_OVERNIGHT'; // valid values STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, ...
     $config['origincountry'] = Country::CodeById($config['origincountry']);
     $config['originstate'] = State::CodeById($config['originstate']);
     if ($config['origincountry'] != "CA" && $config['origincountry'] != "US") {
         //Only required for these countries
         $config['originstate'] = "";
     }
     $request['RequestedShipment']['PackagingType'] = $config['packaging'];
     $request['RequestedShipment']['Shipper'] = array('Address' => array('StreetLines' => array($config['originadde']), 'City' => $config['origincity'], 'StateOrProvinceCode' => $config['originstate'], 'PostalCode' => $config['originpostcode'], 'CountryCode' => $config['origincountry']));
     if ($country != "CA" && $country != "US") {
         //Only required for these countries
         $state = "";
     }
     $request['RequestedShipment']['Recipient'] = array('Address' => array('StreetLines' => array($address1, $address2), 'City' => $city, 'StateOrProvinceCode' => $state, 'PostalCode' => $zipcode, 'CountryCode' => $country, 'Residential' => $this->CheckoutForm->shippingResidential == 1 ? 1 : 0));
     $request['RequestedShipment']['ShippingChargesPayment'] = array('PaymentType' => 'SENDER', 'Payor' => array('AccountNumber' => $config['accnumber'], 'CountryCode' => $config['origincountry']));
     $request['RequestedShipment']['RateRequestTypes'] = 'ACCOUNT';
     $request['RequestedShipment']['RateRequestTypes'] = 'LIST';
     if ($config['origincountry'] != $country && $config['customs'] == "CLEARANCEFEE") {
         $request['RequestedShipment']['InternationalDetail'] = array('CustomsValue' => array('Amount' => $cart->subtotal, 'Currency' => _xls_get_conf('CURRENCY_DEFAULT', 'USD')));
     }
     $request['RequestedShipment']['PackageCount'] = '1';
     $request['RateRequest']['CurrencyType'] = _xls_get_conf('CURRENCY_DEFAULT', 'USD');
     $request['RequestedShipment']['PackageDetail'] = 'INDIVIDUAL_PACKAGES';
     if ($length + $width + $height == 0) {
         $request['RequestedShipment']['RequestedPackageLineItems'] = array('0' => array('SequenceNumber' => '1', 'InsuredValue' => array('Amount' => $cart->subtotal, 'Currency' => _xls_get_conf('CURRENCY_DEFAULT', 'USD')), 'ItemDescription' => 'Ordered items', 'Weight' => array('Value' => $weight, 'Units' => 'LB'), 'CustomerReferences' => array('CustomerReferenceType' => 'CUSTOMER_REFERENCE', 'Value' => _xls_get_conf('STORE_NAME', 'Web Order'))));
     } else {
         $request['RequestedShipment']['RequestedPackageLineItems'] = array('0' => array('SequenceNumber' => '1', 'InsuredValue' => array('Amount' => $cart->subtotal, 'Currency' => _xls_get_conf('CURRENCY_DEFAULT', 'USD')), 'ItemDescription' => 'Ordered items', 'Weight' => array('Value' => $weight, 'Units' => 'LB'), 'Dimensions' => array('Length' => $length, 'Width' => $width, 'Height' => $height, 'Units' => 'IN'), 'CustomerReferences' => array('CustomerReferenceType' => 'CUSTOMER_REFERENCE', 'Value' => _xls_get_conf('STORE_NAME', 'Web Order'))));
     }
     try {
         $response = $client->getRates($request);
         Yii::log(get_class($this) . " sending " . print_r($request, true), $this->logLevel, 'application.' . __CLASS__ . "." . __FUNCTION__);
         Yii::log(get_class($this) . " receiving " . print_r($response, true), $this->logLevel, 'application.' . __CLASS__ . "." . __FUNCTION__);
         if ($response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR') {
             if (isset($response->RateReplyDetails)) {
                 if (is_array($response->RateReplyDetails) === false) {
                     $response->RateReplyDetails = array($response->RateReplyDetails);
                 }
                 foreach ($response->RateReplyDetails as $rateReply) {
//.........这里部分代码省略.........
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:101,代码来源:fedex.php

示例3: GetTaxRateGrid

 /**
  * For a product, returns tax rate for all defined destinations
  * Useful for RSS exports
  * @return TaxGrid[]
  */
 public function GetTaxRateGrid()
 {
     $arrGrid = array();
     $intTaxStatus = $this->tax_status_id;
     $objStatus = TaxStatus::LoadByLS($intTaxStatus);
     $objDestinations = Destination::model()->findAll();
     foreach ($objDestinations as $objDestination) {
         //Because of differences in how Google defines zip code ranges, we can't convert our ranges
         //to theirs. At this time we won't be able to support zip code ranges
         if (!is_null($objDestination->country) && $objDestination->Zipcode1 == '') {
             $objTaxCode = TaxCode::LoadByLS($objDestination->taxcode);
             //print_r($objTaxCode);
             $fltRate = 0.0;
             for ($x = 1; $x <= 5; $x++) {
                 $statusstring = "tax" . $x . "_status";
                 $codestring = "tax" . $x . "_rate";
                 if ($objStatus->{$statusstring} == 0) {
                     $fltRate += $objTaxCode->{$codestring};
                 }
             }
             //Our four elements
             $strCountry = Country::CodeById($objDestination->country);
             if (!is_null($objDestination->state)) {
                 $strState = State::CodeById($objDestination->state);
             } else {
                 $strState = '';
             }
             //$fltRate -- built above
             $strTaxShip = Yii::app()->params['SHIPPING_TAXABLE'] == '1' ? "y" : "n";
             $arrGrid[] = array($strCountry, $strState, $fltRate, $strTaxShip);
         }
     }
     return $arrGrid;
 }
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:39,代码来源:Product.php

示例4: __get

 public function __get($strName)
 {
     switch ($strName) {
         case 'state':
             return State::CodeById($this->state_id);
         case 'country':
             return Country::CodeById($this->country_id);
         case 'mainname':
         case 'full_name':
             return $this->first_name . " " . $this->last_name;
         case 'block':
             return $this->address1 . chr(13) . $this->address2 . chr(13) . $this->city . chr(13) . $this->state . chr(13) . " " . $this->postal . chr(13) . $this->country;
         case 'shipblock':
             return $this->first_name . " " . $this->last_name . (!empty($this->company) ? chr(13) . $this->company : "") . $this->company . chr(13) . $this->address1 . chr(13) . $this->address2 . chr(13) . $this->city . chr(13) . $this->state . chr(13) . " " . $this->postal . chr(13) . $this->country;
         default:
             return parent::__get($strName);
     }
 }
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:18,代码来源:Customer.php

示例5: __get

 public function __get($strName)
 {
     switch ($strName) {
         case 'state':
             if ($this->state_id) {
                 return State::CodeById($this->state_id);
             } else {
                 return null;
             }
         case 'country':
             if ($this->country_id) {
                 return Country::CodeById($this->country_id);
             } else {
                 return null;
             }
         case 'country_name':
             if ($this->country_id) {
                 return Country::CountryById($this->country_id);
             } else {
                 return null;
             }
         case 'mainname':
         case 'fullname':
             return $this->first_name . " " . $this->last_name;
         case 'block':
             return $this->address1 . chr(13) . $this->address2 . chr(13) . $this->city . chr(13) . $this->state . chr(13) . $this->postal . chr(13) . $this->country;
         case 'htmlblock':
             return $this->address1 . '<br>' . (!empty($this->address2) ? $this->address2 . "<br>" : "") . $this->city . ' ' . $this->state . " " . $this->postal . '<br>' . $this->country_name;
         case 'shipblock':
             return $this->first_name . " " . $this->last_name . chr(13) . $this->address1 . chr(13) . (!empty($this->company) ? $this->company . " " . $this->address2 : $this->address2) . chr(13) . $this->city . chr(13) . $this->state . " " . $this->postal . chr(13) . $this->country;
         case 'formattedblock':
             if ($this->customer_id == Yii::app()->user->id) {
                 return $this->first_name . " " . $this->last_name . '<br>' . $this->address1 . '<br>' . (!empty($this->company) ? $this->company . "<br>" : "") . (!empty($this->address2) ? $this->address2 . "<br>" : "") . $this->city . ' ' . $this->state . " " . $this->postal . '<br>' . (_xls_country() != $this->country ? $this->country : "");
             } else {
                 return Yii::t('global', 'Directly to gift recipient') . '<br>' . $this->first_name . " " . $this->last_name;
             }
         case 'formattedblockcountry':
             return $this->first_name . " " . $this->last_name . '<br>' . $this->address1 . '<br>' . (!empty($this->company) ? $this->company . "<br>" : "") . (!empty($this->address2) ? $this->address2 . "<br>" : "") . $this->city . ' ' . $this->state . " " . $this->postal . '<br>' . (_xls_country() != $this->country ? $this->country_name : "");
         default:
             return parent::__get($strName);
     }
 }
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:42,代码来源:CustomerAddress.php

示例6: LoadMatching

 /**
  * Match a given address to the most accurate Destination
  * @param string $country
  * @param string $state
  * @param string $zip
  * @return object :: The matching destination
  */
 public static function LoadMatching($country, $state, $zip)
 {
     //We may get id numbers instead of text strings so convert here
     if (is_numeric($country)) {
         $country = Country::CodeById($country);
     }
     if (is_numeric($state)) {
         $state = State::CodeById($state);
     }
     $arrDestinations = Destination::LoadByCountry($country);
     if (is_array($arrDestinations) === false && $arrDestinations instanceof Traversable === false) {
         return null;
     }
     $objState = State::LoadByCode($state, $country);
     $zip = preg_replace('/[^A-Z0-9]/', '', strtoupper($zip));
     foreach ($arrDestinations as $objDestination) {
         if ($objDestination->state == null || $objState !== null && $objState->id == $objDestination->state) {
             $zipStart = $objDestination->Zipcode1;
             $zipEnd = $objDestination->Zipcode2;
             if ($zipStart <= $zip && $zipEnd >= $zip || $zipStart == '' || $zipStart == '*' || $zip == '') {
                 return $objDestination;
             }
         }
     }
     return null;
 }
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:33,代码来源:Destination.php

示例7: _xls_html_billingaddress

function _xls_html_billingaddress($objCart)
{
    if ($objCart === null) {
        $objCart = Yii::app()->shoppingcart;
    }
    if ($objCart->billaddress_id === null) {
        return '';
    }
    if ($objCart->shipaddress_id == $objCart->billaddress_id) {
        return _xls_html_shippingaddress($objCart);
    }
    $str = '';
    $str .= $objCart->billaddress->address1 . '<br>';
    $str .= $objCart->billaddress->address2 ? $objCart->billaddress->address2 . '<br>' : '';
    $str .= $objCart->billaddress->city . ', ';
    $str .= $objCart->billaddress->state_id ? State::CodeById($objCart->billaddress->state_id) . ', ' : '';
    $str .= $objCart->billaddress->postal ? $objCart->billaddress->postal . '<br>' : '';
    if (_xls_get_conf('DEFAULT_COUNTRY') != $objCart->billaddress->country_id) {
        $str .= Country::CountryById($objCart->billaddress->country_id);
    }
    return $str;
}
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:22,代码来源:helpers.php


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