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


PHP WPSC_Countries::get_continent方法代码示例

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


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

示例1: getQuote

 /**
  * returns shipping quotes using this shipping module.
  *
  * @param boolean $for_display (optional) (unused)
  * @return array collection of rates applicable.
  */
 function getQuote($for_display = false)
 {
     global $wpdb, $wpsc_cart;
     $quote_shipping_method = wpsc_get_customer_meta('quote_shipping_method');
     $quote_shipping_option = wpsc_get_customer_meta('quote_shipping_option');
     $country = '';
     if (isset($_POST['country'])) {
         $country = sanitize_text_field($_POST['country']);
         wpsc_update_customer_meta('shipping_country', $country);
     } else {
         $country = (string) wpsc_get_customer_meta('shipping_country');
     }
     if (is_object($wpsc_cart)) {
         $cart_total = $wpsc_cart->calculate_subtotal(true);
     }
     if (get_option('base_country') != $country) {
         $results = WPSC_Countries::get_continent($country);
         $flatrates = get_option('flat_rates');
         if ($flatrates != '') {
             if ($quote_shipping_method == $this->internal_name && $quote_shipping_option != __("Flat Rate", 'wp-e-commerce')) {
                 wpsc_delete_customer_meta('quote_shipping_option');
             }
             if (isset($flatrates[$results])) {
                 if (stristr($flatrates[$results], '%')) {
                     $shipping_percent = str_replace('%', '', $flatrates[$results]);
                     $shipping_amount = $cart_total * ($shipping_percent / 100);
                     $flatrates[$results] = (double) $shipping_amount;
                 }
                 return array(__("Flat Rate", 'wp-e-commerce') => (double) $flatrates[$results]);
             }
         }
     } else {
         $flatrates = get_option('flat_rates');
         $shipping_quotes = array();
         switch ($country) {
             case 'NZ':
                 if (isset($flatrates['northisland']) && strlen($flatrates['northisland']) > 0) {
                     $shipping_quotes[__('North Island', 'wp-e-commerce')] = esc_attr($flatrates['northisland']);
                 }
                 if (isset($flatrates['southisland']) && strlen($flatrates['southisland']) > 0) {
                     $shipping_quotes[__('South Island', 'wp-e-commerce')] = esc_attr($flatrates['southisland']);
                 }
                 break;
             case 'US':
                 if (isset($flatrates['continental']) && strlen($flatrates['continental']) > 0) {
                     $shipping_quotes[__('Continental 48 States', 'wp-e-commerce')] = esc_attr($flatrates['continental']);
                 }
                 if (isset($flatrates['all']) && strlen($flatrates['all']) > 0) {
                     $shipping_quotes[__('All 50 States', 'wp-e-commerce')] = esc_attr($flatrates['all']);
                 }
                 break;
             default:
                 if (isset($flatrates['local']) && strlen($flatrates['local']) > 0) {
                     $shipping_quotes[__('Local Shipping', 'wp-e-commerce')] = esc_attr($flatrates['local']);
                 }
                 break;
         }
         // Deal with % shipping rates
         foreach (array_keys($shipping_quotes) as $quote_name) {
             if (stristr($shipping_quotes[$quote_name], '%')) {
                 $shipping_percent = str_replace('%', '', $shipping_quotes[$quote_name]);
                 $shipping_amount = $cart_total * ($shipping_percent / 100);
                 $shipping_quotes[$quote_name] = (double) $shipping_amount;
             } else {
                 $shipping_quotes[$quote_name] = (double) $shipping_quotes[$quote_name];
             }
         }
         if ($quote_shipping_method == $this->internal_name) {
             $shipping_options = array_keys($shipping_quotes);
             if (array_search($quote_shipping_option, $shipping_options) === false) {
                 wpsc_delete_customer_meta('quote_shipping_option');
             }
         }
         return $shipping_quotes;
     }
 }
开发者ID:ashik968,项目名称:digiplot,代码行数:82,代码来源:flatrate.php


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