本文整理汇总了PHP中WPSC_Country::get_currency_code方法的典型用法代码示例。如果您正苦于以下问题:PHP WPSC_Country::get_currency_code方法的具体用法?PHP WPSC_Country::get_currency_code怎么用?PHP WPSC_Country::get_currency_code使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPSC_Country
的用法示例。
在下文中一共展示了WPSC_Country::get_currency_code方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2:
function test_get_currency_code()
{
$country = new WPSC_Country(self::COUNTRY_ID_WITHOUT_REGIONS);
$currency_code = $country->get_currency_code();
$this->assertEquals(self::COUNTRY_NAME_WITHOUT_REGIONS_CURRENCY_CODE, $currency_code);
}
示例3: 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;
}
示例4: 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());
}
示例5: wpsc_price_control_forms
function wpsc_price_control_forms()
{
global $post, $wpdb, $variations_processor, $wpsc_product_defaults;
$product_data = get_post_custom($post->ID);
$product_data['meta'] = maybe_unserialize($product_data);
foreach ($product_data['meta'] as $meta_key => $meta_value) {
$product_data['meta'][$meta_key] = $meta_value[0];
}
$product_meta = array();
if (!empty($product_data['_wpsc_product_metadata'])) {
$product_meta = maybe_unserialize($product_data['_wpsc_product_metadata'][0]);
}
if (isset($product_data['meta']['_wpsc_currency'])) {
$product_alt_currency = maybe_unserialize($product_data['meta']['_wpsc_currency']);
}
if (!isset($product_data['meta']['_wpsc_table_rate_price'])) {
$product_data['meta']['_wpsc_table_rate_price'] = $wpsc_product_defaults['meta']['table_rate_price'];
}
if (isset($product_meta['_wpsc_table_rate_price'])) {
$product_meta['table_rate_price']['state'] = 1;
$product_meta['table_rate_price'] += $product_meta['_wpsc_table_rate_price'];
$product_data['meta']['_wpsc_table_rate_price'] = $product_meta['_wpsc_table_rate_price'];
}
if (!isset($product_data['meta']['_wpsc_is_donation'])) {
$product_data['meta']['_wpsc_is_donation'] = $wpsc_product_defaults['donation'];
}
if (!isset($product_meta['table_rate_price']['state'])) {
$product_meta['table_rate_price']['state'] = null;
}
if (!isset($product_meta['table_rate_price']['quantity'])) {
$product_meta['table_rate_price']['quantity'] = $wpsc_product_defaults['meta']['table_rate_price']['quantity'][0];
}
if (!isset($product_data['meta']['_wpsc_price'])) {
$product_data['meta']['_wpsc_price'] = $wpsc_product_defaults['price'];
}
if (!isset($product_data['special'])) {
$product_data['special'] = $wpsc_product_defaults['special'];
}
if (!isset($product_data['meta']['_wpsc_special_price'])) {
$product_data['meta']['_wpsc_special_price'] = $wpsc_product_defaults['special_price'];
}
$product_data['meta']['_wpsc_special_price'] = wpsc_format_number($product_data['meta']['_wpsc_special_price']);
if (!isset($product_data['meta']['_wpsc_price'])) {
$product_data['meta']['_wpsc_price'] = 0;
}
$product_data['meta']['_wpsc_price'] = wpsc_format_number($product_data['meta']['_wpsc_price']);
$currency_data = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY `country` ASC", ARRAY_A);
/* Get country name and symbol */
$currency_type = get_option('currency_type');
$country = new WPSC_Country($currency_type);
$ct_code = $country->get_currency_code();
// Country currency code
$ct_symb = $country->get_currency_symbol();
// Country symbol
$price = $product_data['meta']['_wpsc_price'];
$sale_price = $product_data['meta']['_wpsc_special_price'];
$wp_38 = version_compare($GLOBALS['wp_version'], '3.8', '>=');
$currency_delete_class = $wp_38 ? ' dashicons dashicons-dismiss' : '';
$currency_delete_text = $wp_38 ? '' : 'x';
?>
<em id="wpsc_product_price_metabox_live_title" class="wpsc_metabox_live_title">
<p> <?php
echo esc_html($ct_symb);
?>
<span><?php
echo esc_html($sale_price);
?>
</span></p>
<del><?php
echo esc_html($ct_symb);
?>
<span><?php
echo esc_html($price);
?>
</span></del>
</em>
<input type="hidden" id="parent_post" name="parent_post" value="<?php
echo $post->post_parent;
?>
" />
<?php
/* Lots of tedious work is avoided with this little line. */
?>
<input type="hidden" id="product_id" name="product_id" value="<?php
echo $post->ID;
?>
" />
<?php
/* Check product if a product has variations */
?>
<?php
if (wpsc_product_has_children($post->ID)) {
?>
<?php
$price = wpsc_product_variation_price_from($post->ID);
?>
<p style="margin-top: 6px;"><?php
echo sprintf(__('This product has variations. To edit the price, please use the <a href="%s">Variation Controls</a>.', 'wp-e-commerce'), '#wpsc_product_variation_forms');
?>
//.........这里部分代码省略.........