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


PHP WPSC_Countries::get_region_id方法代码示例

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


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

示例1: __construct

 /**
  * constructor for a region object
  *
  * If null is passed for parameters an empty region is created
  *
  * @access public
  *
  * @since 3.8.14
  *
  * @param int|string|null       required    $country    The country identifier, can be the string ISO code,
  *                                                      or the numeric wpec country id
  *
  * @param int|string|null|array required    $region     The region identifier, can be the text region code,
  *                                                      or the numeric region id, if an array is passed a
  *                                                      new region will be created and saved in the permanent
  *                                                      data store
  */
 public function __construct($country, $region)
 {
     // if a country id or code is passed make sure we have a valid country_id
     $country_id = $country ? WPSC_Countries::get_country_id($country) : 0;
     // if we are creating a region use the country_id we just validated and get the region code
     if (is_array($region)) {
         $region['country_id'] = $country_id;
         $region_id_or_code = $this->_save_region_data($region);
     } else {
         $region_id_or_code = $region;
     }
     // if we have both a country country id and a region id/code we can construct this object
     if ($country && $region_id_or_code) {
         $region_id = WPSC_Countries::get_region_id($country_id, $region_id_or_code);
         if ($country_id && $region_id) {
             $wpsc_country = new WPSC_Country($country_id);
             $wpsc_region = $wpsc_country->get_region($region_id);
             if ($wpsc_region) {
                 $this->_code = $wpsc_region->_code;
                 $this->_id = $wpsc_region->_id;
                 $this->_country_id = $wpsc_region->_country_id;
                 $this->_name = $wpsc_region->_name;
                 $this->_tax = $wpsc_region->_tax;
             }
         }
     }
 }
开发者ID:osuarcher,项目名称:WP-e-Commerce,代码行数:44,代码来源:wpsc-region.class.php

示例2: set_customer_details

 public function set_customer_details()
 {
     $_POST['wpsc_checkout_details'] = array();
     $_GET['amazon_reference_id'] = sanitize_text_field($_POST['amazon_reference_id']);
     try {
         if (!$this->reference_id) {
             throw new Exception(__('An Amazon payment method was not chosen.', 'wpsc'));
         }
         if (is_null($this->purchase_log)) {
             $log = _wpsc_get_current_controller()->get_purchase_log();
             wpsc_update_customer_meta('current_purchase_log_id', $log->get('id'));
             $this->set_purchase_log($log);
         }
         global $wpsc_cart;
         // Update order reference with amounts
         $response = $this->api_request(array('Action' => 'SetOrderReferenceDetails', 'AmazonOrderReferenceId' => $this->reference_id, 'OrderReferenceAttributes.OrderTotal.Amount' => $wpsc_cart->calculate_total_price(), 'OrderReferenceAttributes.OrderTotal.CurrencyCode' => strtoupper($this->get_currency_code()), 'OrderReferenceAttributes.SellerNote' => sprintf(__('Order %s from %s.', 'wpsc'), $this->purchase_log->get('id'), urlencode(remove_accents(wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)))), 'OrderReferenceAttributes.SellerOrderAttributes.SellerOrderId' => $this->purchase_log->get('id'), 'OrderReferenceAttributes.SellerOrderAttributes.StoreName' => remove_accents(wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)), 'OrderReferenceAttributes.PlatformId' => 'A2Z8DY3R4G08IM'));
         if (is_wp_error($response)) {
             throw new Exception($response->get_error_message());
         }
         if (isset($response['Error']['Message'])) {
             throw new Exception($response['Error']['Message']);
         }
         $response = $this->api_request(array('Action' => 'GetOrderReferenceDetails', 'AmazonOrderReferenceId' => $this->reference_id));
         if (is_wp_error($response)) {
             throw new Exception($response->get_error_message());
         }
         if (!isset($response['GetOrderReferenceDetailsResult']['OrderReferenceDetails']['Destination']['PhysicalDestination'])) {
             return;
         }
         $address = $response['GetOrderReferenceDetailsResult']['OrderReferenceDetails']['Destination']['PhysicalDestination'];
         remove_action('wpsc_checkout_get_fields', '__return_empty_array');
         add_filter('wpsc_validate_form', '__return_true');
         $form = WPSC_Checkout_Form::get();
         $fields = $form->get_fields();
         foreach ($fields as $field) {
             switch ($field->unique_name) {
                 case 'shippingstate':
                     $_POST['wpsc_checkout_details'][$field->id] = WPSC_Countries::get_region_id($address['CountryCode'], $address['StateOrRegion']);
                     break;
                 case 'shippingcountry':
                     $_POST['wpsc_checkout_details'][$field->id] = $address['CountryCode'];
                     break;
                 case 'shippingpostcode':
                     $_POST['wpsc_checkout_details'][$field->id] = $address['PostalCode'];
                     break;
                 case 'shippingcity':
                     $_POST['wpsc_checkout_details'][$field->id] = $address['City'];
                     break;
             }
         }
     } catch (Exception $e) {
         WPSC_Message_Collection::get_instance()->add($e->getMessage(), 'error', 'main', 'flash');
         return;
     }
 }
开发者ID:RJHanson292,项目名称:WP-e-Commerce,代码行数:55,代码来源:amazon-payments.php


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