• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP WPSC_Country类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了WPSC_Country类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: _wpsc_add_region_name_meta

/**
 * 3.8.14 supports country meta and a feature that let's a countries regions be called by the
 * proper name.  Here we initialize the values.
 *
 * @access private
 * @since 3.8.14
 *
 */
function _wpsc_add_region_name_meta()
{
    $wpsc_country = new WPSC_Country('US');
    $wpsc_country->set('region_label', __('State', 'wp-e-commerce'));
    $wpsc_country = new WPSC_Country('CA');
    $wpsc_country->set('region_label', __('Province', 'wp-e-commerce'));
}
开发者ID:ashik968,项目名称:digiplot,代码行数:15,代码来源:10.php


示例3: wpsc_format_currency

/**
 * Format a price amount.
 *
 * The available options that you can specify in the $args argument include:
 *     'display_currency_symbol' - Whether to attach the currency symbol to the figure.
 *                                 Defaults to true.
 *     'display_decimal_point'   - Whether to display the decimal point.
 *                                 Defaults to true.
 *     'display_currency_code'   - Whether to attach the currency code to the figure.
 *                                 Defaults to fault.
 *     'isocode'                 - Specify the isocode of the base country that you want to use for
 *                                 this price.
 *                                 Defaults to the settings in Settings->Store->General.
 *
 * @since 4.0
 * @uses  apply_filters() Applies 'wpsc_format_currency'                     filter
 * @uses  apply_filters() Applies 'wpsc_format_currency_currency_code'       filter.
 * @uses  apply_filters() Applies 'wpsc_format_currency_currency_symbol'     filter.
 * @uses  apply_filters() Applies 'wpsc_format_currency_decimal_separator'   filter.
 * @uses  apply_filters() Applies 'wpsc_format_currency_thousands_separator' filter.
 * @uses  apply_filters() Applies 'wpsc_modify_decimals' filter.
 * @uses  get_option()    Gets the value of 'currency_sign_location' in Settings->Store->General.
 * @uses  get_option()    Gets the value of 'currency_type' in Settings->Store->General.
 * @uses  WPSC_Country::__construct()
 * @uses  WPSC_Country::get()
 * @uses  wp_parse_args()
 *
 * @param  float|int|string $amt  The price you want to format.
 * @param  string|array     $args A query string or array containing the options. Defaults to ''.
 * @return string                 The formatted price.
 */
function wpsc_format_currency($amt, $args = '')
{
    $defaults = array('display_currency_symbol' => true, 'display_decimal_point' => true, 'display_currency_code' => false, 'isocode' => false, 'currency_code' => false);
    $args = wp_parse_args($args);
    // Either display symbol or code, not both
    if (array_key_exists('display_currency_symbol', $args)) {
        $args['display_currency_code'] = !$args['display_currency_symbol'];
    } elseif (array_key_exists('display_currency_code', $args)) {
        $args['display_currency_symbol'] = !$args['display_currency_code'];
    }
    $r = wp_parse_args($args, $defaults);
    extract($r);
    $currencies_without_fractions = WPSC_Payment_Gateways::currencies_without_fractions();
    if ($isocode) {
        $currency = new WPSC_Country($isocode);
    } else {
        $currency = new WPSC_Country(get_option('currency_type'));
    }
    $currency_code = $currency->get_currency_code();
    // No decimal point, no decimals
    if (!$display_decimal_point || in_array($currency_code, $currencies_without_fractions)) {
        $decimals = 0;
    } else {
        $decimals = 2;
        // default is 2
    }
    $decimals = apply_filters('wpsc_modify_decimals', $decimals, $isocode);
    $decimal_separator = apply_filters('wpsc_format_currency_decimal_separator', wpsc_get_option('decimal_separator'), $isocode);
    $thousands_separator = apply_filters('wpsc_format_currency_thousands_separator', wpsc_get_option('thousands_separator'), $isocode);
    // Format the price for output
    $formatted = number_format($amt, $decimals, $decimal_separator, $thousands_separator);
    if (!$display_currency_code) {
        $currency_code = '';
    }
    $symbol = $display_currency_symbol ? $currency->get_currency_symbol() : '';
    $symbol = esc_html($symbol);
    $symbol = apply_filters('wpsc_format_currency_currency_symbol', $symbol, $isocode);
    $currency_sign_location = get_option('currency_sign_location');
    // Rejig the currency sign location
    switch ($currency_sign_location) {
        case 1:
            $format_string = '%3$s%1$s%2$s';
            break;
        case 2:
            $format_string = '%3$s %1$s%2$s';
            break;
        case 4:
            $format_string = '%1$s%2$s  %3$s';
            break;
        case 3:
        default:
            $format_string = '%1$s %2$s%3$s';
            break;
    }
    $currency_code = apply_filters('wpsc_format_currency_currency_code', $currency_code, $isocode);
    // Compile the output
    $output = trim(sprintf($format_string, $currency_code, $symbol, $formatted));
    return $output;
}
开发者ID:ashik968,项目名称:digiplot,代码行数:90,代码来源:common.php


示例4: _wpsc_maybe_create_UK

function _wpsc_maybe_create_UK()
{
    $country = new WPSC_Country('GB', 'isocode');
    if (!$country->exists()) {
        $country->set(array('id' => 138, 'country' => __('United Kingdom', 'wpsc'), 'currency' => __('Pound Sterling', 'wpsc'), 'symbol' => __('£', 'wpsc'), 'symbol_html' => __('£', 'wpsc'), 'code' => __('GBP', 'wpsc'), 'continent' => 'europe'));
        $country->save();
    }
}
开发者ID:pankajsinghjarial,项目名称:SYLC,代码行数:8,代码来源:3.php


示例5: wpsc_format_price

function wpsc_format_price($amt, $currency = false)
{
    $currencies_without_fractions = array('JPY', 'HUF');
    if (!$currency) {
        $country = new WPSC_Country(get_option('currency_type'));
        $currency = $country->get('code');
    }
    $dec = in_array($currency, $currencies_without_fractions) ? 0 : 2;
    return number_format($amt, $dec);
}
开发者ID:nikitanaumov,项目名称:WP-e-Commerce,代码行数:10,代码来源:purchase-log.helpers.php


示例6: _wpsc_fix_united_kingdom

/**
 * Reset United Kingdom country data to default, hide ISO code 'UK'
 *
 * @access private
 * @since 3.8.14
 */
function _wpsc_fix_united_kingdom()
{
    if ($wpsc_country = WPSC_Countries::get_country('UK')) {
        $legacy_ok_country_was_visible = $wpsc_country->is_visible();
        $wpsc_country = new WPSC_Country(array('visible' => '0', 'isocode' => 'UK'));
        $wpsc_country->set('_is_country_legacy', true);
    }
    $wpsc_country = new WPSC_Country(array('country' => __('United Kingdom', 'wpsc'), 'isocode' => 'GB', 'currency' => __('Pound Sterling', 'wpsc'), 'symbol' => __('£', 'wpsc'), 'symbol_html' => __('£', 'wpsc'), 'code' => __('GBP', 'wpsc'), 'continent' => 'europe', 'visible' => $legacy_ok_country_was_visible ? '0' : '1', 'has_regions' => '0', 'tax' => '0'));
    //make sure base country is ok after the UK/GB fix
    $base_country = get_option('base_country', '');
    if (!empty($base_country) && is_numeric($base_country)) {
        $wpsc_country = new WPSC_Country($base_country);
        if ('UK' == $wpsc_country->get_isocode()) {
            $wpsc_country = new WPSC_Country('GB');
            update_option('base_country', $wpsc_country->get_id());
        }
    }
}
开发者ID:dreamteam111,项目名称:dreamteam,代码行数:24,代码来源:11.php


示例7: _wpsc_updated_visitor_meta_billingcountry

/**
 * Update any values dependant on billing country
 *
 * @since 3.8.14
 *
 * @access private
 * @param mixed $meta_value Optional. Metadata value.
 * @param string $meta_key Metadata name.
 * @param int $visitor_id visitor ID
 * @return none
*/
function _wpsc_updated_visitor_meta_billingcountry($meta_value, $meta_key, $visitor_id)
{
    $old_billing_state = wpsc_get_visitor_meta($visitor_id, 'billingstate', true);
    $old_billing_region = wpsc_get_visitor_meta($visitor_id, 'billingregion', true);
    if (!empty($meta_value)) {
        // check the current state and region values, if either isn't valid for the new country delete them
        $wpsc_country = new WPSC_Country($meta_value);
        if (!empty($old_billing_state) && $wpsc_country->has_regions() && !$wpsc_country->has_region($old_billing_state)) {
            wpsc_delete_visitor_meta($visitor_id, 'billingstate');
        }
        if (!empty($old_billing_region) && $wpsc_country->has_regions() && !$wpsc_country->has_region($old_billing_region)) {
            wpsc_delete_visitor_meta($visitor_id, 'billingregion');
        }
    } else {
        wpsc_delete_visitor_meta($visitor_id, 'billingstate');
        wpsc_delete_visitor_meta($visitor_id, 'billingregion');
    }
}
开发者ID:VanessaGarcia-Freelance,项目名称:ButtonHut,代码行数:29,代码来源:wpsc-meta-visitor.php


示例8: wpsc_base_country_code

/**
 * Template tag for base country currency code.
 *
 * Helpful for templates using structured data, likely other use cases.
 * Temporarily located here, until #1865 lands.
 *
 * @since  4.0
 *
 * @return  string Base country currency code.
 */
function wpsc_base_country_code()
{
    $base = new WPSC_Country(wpsc_get_base_country());
    echo esc_attr($base->get_currency_code());
}
开发者ID:RJHanson292,项目名称:WP-e-Commerce,代码行数:15,代码来源:product.php


示例9: _wpsc_create_south_sudan

function _wpsc_create_south_sudan()
{
    $country = new WPSC_Country(array('id' => '242', 'country' => __('South Sudan', 'wpsc'), 'isocode' => __('SS', 'wpsc'), 'currency' => __('South Sudanese Pound', 'wpsc'), 'code' => __('SSP', 'wpsc'), 'continent' => 'africa'));
    $country->save();
}
开发者ID:pankajsinghjarial,项目名称:SYLC,代码行数:5,代码来源:1.php


示例10: _wpsc_acceptable_shipping_countries_into_checkout_page

/**
 * On the checkout page create a hidden element holding the acceptable shipping countries
 *
 * This let's the wp-e-commerce javascript process any dependency rules even if the store has configured
 * the checkout forms so that some fields are hidden.  The most important of these fields are the
 * country, region and state fields. But it's just as easy to include all of them and not worry about
 * what various parts of WPeC, themes or plugs may be doing.
 *
 * @since 3.8.14
 *
 * @access private
 */
function _wpsc_acceptable_shipping_countries_into_checkout_page()
{
    $acceptable_countries = wpsc_get_acceptable_countries();
    // if the acceptable countries is true all available countries can be shipped to,
    // otherwise we are going to restrict the countries list
    if ($acceptable_countries !== true) {
        $country_code_list = array();
        foreach ($acceptable_countries as $key => $country_id) {
            $wpsc_country = new WPSC_Country($country_id);
            $country_code_list[$wpsc_country->get_isocode()] = $wpsc_country->get_name();
        }
        ?>
		<script type="text/javascript">
		/* <![CDATA[ */
			var wpsc_acceptable_shipping_countries = <?php 
        echo json_encode($country_code_list);
        ?>
;
		/* ]]> */
		</script>
		<?php 
    }
}
开发者ID:osuarcher,项目名称:WP-e-Commerce,代码行数:35,代码来源:checkout-localization.php


示例11: _wpsc_action_admin_notices_deprecated_countries_notice

/**
 * Displays notice if user has Great Britain selected as their base country
 * Since 3.8.9, we have deprecated Great Britain in favor of the UK
 *
 * @since 3.8.9
 * @access private
 * @link http://code.google.com/p/wp-e-commerce/issues/detail?id=1079
 *
 * @uses get_option()             Retrieves option from the WordPress database
 * @uses get_outdate_isocodes()   Returns outdated isocodes
 * @uses admin_url()              Returns admin_url of the site
 *
 * @return string  The admin notices for deprecated countries
 */
function _wpsc_action_admin_notices_deprecated_countries_notice()
{
    $base_country = get_option('base_country');
    if (!in_array($base_country, WPSC_Country::get_outdated_isocodes())) {
        return;
    }
    switch ($base_country) {
        case 'YU':
            $message = __('Yugoslavia is no longer a valid official country name according to <a href="%1$s">ISO 3166</a> while both Serbia and Montenegro have been added to the country list.<br /> As a result, we highly recommend changing your <em>Base Country</em> to reflect this change on the <a href="%2$s">General Settings</a> page.', 'wpsc');
            break;
        case 'UK':
            $message = __('Prior to WP e-Commerce 3.8.9, in your database, United Kingdom\'s country code is UK and you have already selected that country code as the base country. However, now that you\'re using WP e-Commerce version %3$s, it is recommended that you change your base country to the official "GB" country code, according to <a href="%1$s">ISO 3166</a>.<br /> Please go to <a href="%2$s">General Settings</a> page to make this change.<br />The legacy "UK" item will be marked as "U.K. (legacy)" on the country drop down list. Simply switch to the official "United Kingdom (ISO 3166)" to use the "GB" country code.', 'wpsc');
            break;
        case 'AN':
            $message = __('Netherlands Antilles is no longer a valid official country name according to <a href="%1$s">ISO 3166</a>.<br />Please consider changing your <em>Base Country</em> to reflect this change on the <a href="%2$s">General Settings</a> page.', 'wpsc');
        case 'TP':
            $message = __('Prior to WP e-Commerce 3.8.9, in your database, East Timor\'s country code is TP and you have already selected that country code as the base country. However, now that you\'re using WP e-Commerce version %3$s, it is recommended that you change your base country to the official "TL" country code, according to <a href="%1$s">ISO 3166</a>.<br /> Please go to <a href="%2$s">General Settings</a> page to make this change.<br />The legacy "TP" item will be marked as "East Timor (legacy)" on the country drop down list. Simply switch to the official "Timor-Leste (ISO 3166)" to use the "TL" country code.', 'wpsc');
            break;
    }
    $message = sprintf($message, 'http://en.wikipedia.org/wiki/ISO_3166-1', admin_url('options-general.php?page=wpsc-settings&tab=general'), WPSC_VERSION);
    echo '<div id="wpsc-warning" class="error"><p>' . $message . '</p></div>';
}
开发者ID:dreamteam111,项目名称:dreamteam,代码行数:36,代码来源:admin.php


示例12: wpsc_checkout_shipping_state_and_region

/**
 * get the output used to show a shipping state and region select drop down
 *
 * @since 3.8.14
 *
 * @param wpsc_checkout|null  $wpsc_checkout checkout object
 * @return string
 */
function wpsc_checkout_shipping_state_and_region($wpsc_checkout = null)
{
    // just in case the checkout form was not presented, like when we are doing the shipping calculator
    if (empty($wpsc_checkout)) {
        $wpsc_checkout = new wpsc_checkout();
        $doing_checkout_form = false;
    } else {
        $doing_checkout_form = true;
    }
    // if we aren't showing the shipping state on the cor we have no work to do
    if (!$wpsc_checkout->get_checkout_item('shippingstate')) {
        return '';
    }
    // save the current checkout item in case we adjust it in the routine, we'll put it back before return
    $saved_checkout_item = $wpsc_checkout->checkout_item;
    // check a new checkout form with all fields
    $checkout_form = new WPSC_Checkout_Form(null, false);
    // is the shipping country visible on the form, let's find out
    $shipping_country_form_element = $checkout_form->get_field_by_unique_name('shippingcountry');
    $showing_shipping_country = (bool) $shipping_country_form_element->active;
    // make sure the shipping state is the current checkout element
    $wpsc_checkout->checkout_item = $wpsc_checkout->get_checkout_item('shippingstate');
    // setup the edit field, aka 'shippingstate'
    $shipping_country = wpsc_get_customer_meta('shippingcountry');
    $shipping_region = wpsc_get_customer_meta('shippingregion');
    $shipping_state = wpsc_get_customer_meta('shippingstate');
    // if we are showing the billing country on the form then we use the value that can be
    // changed by the user, otherwise we will use the base country as configured in store admin
    if ($showing_shipping_country) {
        $wpsc_country = new WPSC_Country($shipping_country);
    } else {
        $wpsc_country = new WPSC_Country(wpsc_get_base_country());
    }
    $region_list = $wpsc_country->get_regions();
    $placeholder = $wpsc_country->get('region_label');
    if (empty($placeholder)) {
        $placeholder = $wpsc_checkout->checkout_item->name;
    }
    $placeholder = apply_filters('wpsc_checkout_field_placeholder', apply_filters('wpsc_checkout_field_name', $placeholder), $wpsc_checkout->checkout_item);
    $form_element_id = $wpsc_checkout->form_element_id();
    if ($doing_checkout_form) {
        $id_attribute = ' id="' . $form_element_id . '" ';
    } else {
        $id_attribute = '';
    }
    // if there are regions for the current country we are going to
    // create the billing state edit, but hide it
    $style = ' ';
    if (!empty($region_list)) {
        $style = 'style="display: none;"';
    }
    $output = '<input class="shipping_region text  wpsc-visitor-meta" ' . ' data-wpsc-meta-key="' . $wpsc_checkout->checkout_item->unique_name . '" ' . ' title="' . $wpsc_checkout->checkout_item->unique_name . '" ' . ' type="text" ' . $id_attribute . ' placeholder="' . esc_attr($placeholder) . '" ' . ' value="' . esc_attr($shipping_state) . '" ' . ' name="collected_data[' . $wpsc_checkout->checkout_item->id . ']" ' . $style . ' />' . "\n\r";
    // setup the drop down field, aka 'shippingregion'
    // move the checkout item pointer to the billing country, so we can generate form element ids, highly lame
    $wpsc_checkout->checkout_item = $checkout_form->get_field_by_unique_name('shippingcountry');
    // if there aren't any regions for the current country we are going to
    // create the empty region select, but hide it
    $style = ' ';
    if (empty($region_list)) {
        $style = 'style="display: none;"';
    }
    $title = 'shippingregion';
    $region_form_id = $wpsc_checkout->form_element_id() . '_region';
    $output .= '<select id="' . $region_form_id . '" ' . ' class="current_region wpsc-visitor-meta wpsc-region-dropdown" ' . ' data-wpsc-meta-key="shippingregion" ' . ' title="' . $title . '" ' . 'name="collected_data[' . $wpsc_checkout->checkout_item->id . '][1]" ' . $style . ">\n\r";
    $wpsc_current_region = $wpsc_country->get_region($shipping_region);
    if (!empty($region_list)) {
        if (count($region_list) > 1) {
            $label = $wpsc_country->get('region_label');
            $please_select_message = sprintf(__('Please select a %s', 'wp-e-commerce'), $label);
            $output .= "<option value='0'>" . $please_select_message . "</option>\n\r";
        }
        foreach ($region_list as $wpsc_region) {
            if ((bool) $wpsc_current_region && $wpsc_current_region->get_id() == $wpsc_region->get_id()) {
                $selected = "selected='selected'";
            } else {
                $selected = '';
            }
            $output .= "<option value='" . $wpsc_region->get_id() . "' {$selected}>" . esc_html($wpsc_region->get_name()) . "</option>\n\r";
        }
    }
    $output .= "</select>\n\r";
    // restore the checkout item in case we messed with it
    $wpsc_checkout->checkout_item = $saved_checkout_item;
    return $output;
}
开发者ID:ashik968,项目名称:digiplot,代码行数:93,代码来源:shopping_cart_functions.php


示例13: get_tax_rate

 /**
  * get_tax_rate method, gets the tax rate as a percentage, based on the selected country and region
  * * EDIT: Replaced with WPEC Taxes - this function should probably be deprecated
  * Note: to refresh cart items use wpsc_refresh_cart_items
  *
  * @access public
  */
 function get_tax_rate()
 {
     $country = new WPSC_Country(get_option('base_country'));
     $country_data = WPSC_Countries::get_country(get_option('base_country'), true);
     $add_tax = false;
     if ($this->selected_country == get_option('base_country')) {
         // Tax rules for various countries go here, if your countries tax rules
         // deviate from this, please supply code to add your region
         switch ($this->selected_country) {
             case 'US':
                 // USA!
                 $tax_region = get_option('base_region');
                 if ($this->selected_region == get_option('base_region') && get_option('lock_tax_to_shipping') != '1') {
                     // if they in the state, they pay tax
                     $add_tax = true;
                 } else {
                     if ($this->delivery_region == get_option('base_region')) {
                         // if they live outside the state, but are delivering to within the state, they pay tax also
                         $add_tax = true;
                     }
                 }
                 break;
             case 'CA':
                 // Canada! apparently in canada, the region that you are in is used for tax purposes
                 if ($this->selected_region != null) {
                     $tax_region = $this->selected_region;
                 } else {
                     $tax_region = get_option('base_region');
                 }
                 $add_tax = true;
                 break;
             default:
                 // Everywhere else!
                 $tax_region = get_option('base_region');
                 if ($country->has_regions()) {
                     if (get_option('base_region') == $region) {
                         $add_tax = true;
                     }
                 } else {
                     $add_tax = true;
                 }
                 break;
         }
     }
     if ($add_tax == true) {
         if ($country->has_regions()) {
             $region = $country->get_region($tax_region);
             $tax_percentage = $region->get_tax();
         } else {
             $tax_percentage = $country->get_tax();
         }
     } else {
         // no tax charged = tax equal to 0%
         $tax_percentage = 0;
     }
     if ($this->tax_percentage != $tax_percentage) {
         $this->clear_cache();
         $this->tax_percentage = $tax_percentage;
         $this->wpsc_refresh_cart_items();
     }
 }
开发者ID:dreamteam111,项目名称:dreamteam,代码行数:68,代码来源:cart.class.php


示例14: get_shipping_method_js_vars

 private function get_shipping_method_js_vars()
 {
     global $wpsc_cart;
     $js_var = array('subtotal' => (double) $wpsc_cart->calculate_subtotal(), 'shipping' => array(), 'tax' => wpsc_is_tax_enabled() && !wpsc_is_tax_included() ? (double) wpsc_cart_tax(false) : 0, 'discount' => wpsc_coupon_amount(false) > 0 ? wpsc_coupon_amount(false) : 0);
     foreach ($this->shipping_calculator->sorted_quotes as $module_name => $quotes) {
         foreach ($quotes as $option => $cost) {
             $id = $this->shipping_calculator->ids[$module_name][$option];
             $js_var['shipping'][$id] = $cost;
         }
     }
     $currency = new WPSC_Country(get_option('currency_type'));
     $currency_code = $currency->get_currency_code();
     $isocode = $currency->get_isocode();
     $without_fractions = in_array($currency_code, WPSC_Payment_Gateways::currencies_without_fractions());
     $decimals = $without_fractions ? 0 : 2;
     $decimals = apply_filters('wpsc_modify_decimals', $decimals, $isocode);
     $decimal_separator = apply_filters('wpsc_format_currency_decimal_separator', wpsc_get_option('decimal_separator'), $isocode);
     $thousands_separator = apply_filters('wpsc_format_currency_thousands_separator', wpsc_get_option('thousands_separator'), $isocode);
     $symbol = apply_filters('wpsc_format_currency_currency_symbol', $currency->get_currency_symbol());
     $sign_location = get_option('currency_sign_location');
     $js_var['formatter'] = array('currency_code' => $currency_code, 'without_fractions' => $without_fractions, 'decimals' => $decimals, 'decimal_separator' => $decimal_separator, 'thousands_separator' => $thousands_separator, 'symbol' => $symbol, 'sign_location' => $sign_location);
     return $js_var;
 }
开发者ID:androidprojectwork,项目名称:WP-e-Commerce,代码行数:23,代码来源:checkout.php


示例15: _create_active_countries_map

 /**
  * callback that creates / re-creates the data map mapping all active country ids to all active countries
  *
  * @access private
  * @since 3.8.14
  *
  * @param WPSC_Data_Map    $data_map     Data map object being intitilized
  */
 public static function _create_active_countries_map($data_map)
 {
     global $wpdb;
     // there are also invisible countries
     $sql = 'SELECT ' . ' id, country, isocode, currency, symbol, symbol_html, code, has_regions, tax, continent, visible ' . ' FROM `' . WPSC_TABLE_CURRENCY_LIST . '` WHERE `visible`= "1" ' . ' ORDER BY id ASC';
     $countries_array = $wpdb->get_results($sql, OBJECT_K);
     // build an array to map from iso code to country, while we do this get any region data for the country
     foreach ($countries_array as $country_id => $country) {
         // create a new empty country object, add the properties we know about, then we add our region info
         $wpsc_country = new WPSC_Country(null);
         $wpsc_country->_copy_properties_from_stdclass($country);
         if ($country->has_regions) {
             $sql = 'SELECT id, code, country_id, name, tax ' . ' FROM `' . WPSC_TABLE_REGION_TAX . '` ' . ' WHERE `country_id` = %d ' . ' ORDER BY code ASC ';
             // put the regions list into our country object
             $regions = $wpdb->get_results($wpdb->prepare($sql, $country_id), OBJECT_K);
             /*
              * any properties that came in as text that should be numbers or boolean
              * get adjusted here, we also build an array to map from region code to region id
              */
             foreach ($regions as $region_id => $region) {
                 $region->id = intval($region_id);
                 $region->country_id = intval($region->country_id);
                 $region->tax = floatval($region->tax);
                 // create a new empty region object, then copy our region data into it.
                 $wpsc_region = new WPSC_Region(null, null);
                 $wpsc_region->_copy_properties_from_stdclass($region);
                 $wpsc_country->_regions->map($region->id, $wpsc_region);
                 $wpsc_country->_region_id_by_region_code->map($region->code, $region->id);
                 $wpsc_country->_region_id_by_region_name->map(strtolower($region->name), $region->id);
             }
         }
         $data_map->map($country_id, $wpsc_country);
     }
     self::$_dirty = true;
 }
开发者ID:RJHanson292,项目名称:WP-e-Commerce,代码行数:43,代码来源:wpsc-countries.class.php


示例16: _wpsc_filter_validation_rule_state_of

function _wpsc_filter_validation_rule_state_of($error, $value, $field, $props, $matched_field, $matched_value, $matched_props)
{
    global $wpdb;
    if ($value == '') {
        return $error;
    }
    $country_code = $_POST['wpsc_checkout_details'][$matched_field];
    $country = new WPSC_Country($country_code);
    if (!$country->has_regions()) {
        return $error;
    }
    // state should have been converted into a numeric value already
    // if not, it's an invalid state
    if (!is_numeric($value)) {
        $message = apply_filters('wpsc_validation_rule_invalid_state_message', __('%1$s is not a valid state or province in %2$s', 'wpsc'));
        $message = sprintf($message, $value, $country->get_name());
        $error->add($field, $message, array('value' => $value, 'props' => $props));
        return $error;
    }
    $sql = $wpdb->prepare('SELECT COUNT(id) FROM ' . WPSC_TABLE_REGION_TAX . ' WHERE id = %d', $value);
    $count = $wpdb->get_var($sql);
    if ($count == 0) {
        $message = apply_filters('wpsc_validation_rule_invalid_state_id_message', __('You specified or were assigned an invalid state or province. Please contact administrator for assistance', 'wpsc'));
        $error->add($field, $message, array('value' => $value, 'props' => $props));
    }
    return $error;
}
开发者ID:osuarcher,项目名称:WP-e-Commerce,代码行数:27,代码来源:form-validation.php


示例17: _wpsc_add_region_label_to_uk

/**
 * Add the county region label to the uk
 *
 * @access private
 * @since 3.8.14.1
 */
function _wpsc_add_region_label_to_uk()
{
    $wpsc_country = new WPSC_Country('GB');
    $wpsc_country->set('region_label', __('County', 'wpsc'));
}
开发者ID:RJHanson292,项目名称:WP-e-Commerce,代码行数:11,代码来源:13.php


示例18: get_full_country

 /**
  * Given an ISO country code, it will return the full country name
  *
  * @since 0.0.1
  * @param string $short_country
  * @return string
  */
 function get_full_country($short_country)
 {
     $country = new WPSC_Country($short_country);
     return $country->get_name();
 }
开发者ID:AngryBird3,项目名称:WP-e-Commerce,代码行数:12,代码来源:shipping.helper.php


示例19: wpsc_get_country

function wpsc_get_country($country_code)
{
    $wpsc_country = new WPSC_Country($country_code);
    return $wpsc_country->get_name();
}
开发者ID:VanessaGarcia-Freelance,项目名称:ButtonHut,代码行数:5,代码来源:misc.functions.php


示例20: wpec_taxes_get_region_code_by_id

 /**
  * @description: wpec_taxes_get_region_code_by_id - given an id this funciton will
  * return the region code.
  * @param: id - a region id
  * @return: int or false
  * */
 function wpec_taxes_get_region_code_by_id($region)
 {
     $region_code = false;
     if (!empty($region)) {
         $country_id = WPSC_Countries::get_country_id_by_region_id($region);
         if ($country_id) {
             $wpsc_country = new WPSC_Country($country_id);
         }
         if (isset($wpsc_country)) {
             $wpsc_region = $wpsc_country->get_region($region);
             if ($wpsc_region) {
                 $region_code = $wpsc_region->get_code();
             }
         }
     }
     return $region_code;
 }
开发者ID:parkesma,项目名称:WP-e-Commerce,代码行数:23,代码来源:taxes.class.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP WPSC_Purchase_Log类代码示例发布时间:2022-05-23
下一篇:
PHP WPSC_Countries类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap