本文整理汇总了PHP中wc_trim_zeros函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_trim_zeros函数的具体用法?PHP wc_trim_zeros怎么用?PHP wc_trim_zeros使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_trim_zeros函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: wc_price
public function wc_price($price, $args = array())
{
$decimals = 2;
extract(apply_filters('wc_price_args', wp_parse_args($args, array('ex_tax_label' => false, 'currency' => '', 'decimal_separator' => $this->decimal_sep, 'thousand_separator' => $this->thousands_sep, 'decimals' => $decimals, 'price_format' => $this->woocommerce_price_format()))));
//***
$currencies = $this->get_currencies();
if (isset($currencies[$currency])) {
if ($currencies[$currency]['hide_cents']) {
$decimals = 0;
}
}
//***
$negative = $price < 0;
$price = apply_filters('raw_woocommerce_price', floatval($negative ? $price * -1 : $price));
$price = apply_filters('formatted_woocommerce_price', number_format($price, $decimals, $decimal_separator, $thousand_separator), $price, $decimals, $decimal_separator, $thousand_separator);
if (apply_filters('woocommerce_price_trim_zeros', false) && $decimals > 0) {
$price = wc_trim_zeros($price);
}
$formatted_price = ($negative ? '-' : '') . sprintf($price_format, get_woocommerce_currency_symbol($currency), $price);
$return = '<span class="woocs_amount">' . $formatted_price . '</span>';
if ($ex_tax_label && wc_tax_enabled()) {
$return .= ' <small class="tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>';
}
return apply_filters('wc_price', $return, $price, $args);
}
开发者ID:Inteleck,项目名称:hwc,代码行数:25,代码来源:index.php
示例2: wc_price
/**
* Format the price with a currency symbol.
*
* @param float $price
* @param array $args (default: array())
* @return string
*/
function wc_price($price, $args = array())
{
extract(apply_filters('wc_price_args', wp_parse_args($args, array('ex_tax_label' => false, 'currency' => '', 'decimal_separator' => wc_get_price_decimal_separator(), 'thousand_separator' => wc_get_price_thousand_separator(), 'decimals' => wc_get_price_decimals(), 'price_format' => get_woocommerce_price_format()))));
$negative = $price < 0;
$price = apply_filters('raw_woocommerce_price', floatval($negative ? $price * -1 : $price));
$price = apply_filters('formatted_woocommerce_price', number_format($price, $decimals, $decimal_separator, $thousand_separator), $price, $decimals, $decimal_separator, $thousand_separator);
if (apply_filters('woocommerce_price_trim_zeros', false) && $decimals > 0) {
$price = wc_trim_zeros($price);
}
$formatted_price = ($negative ? '-' : '') . sprintf($price_format, '<span class="woocommerce-Price-currencySymbol">' . get_woocommerce_currency_symbol($currency) . '</span>', $price);
$return = '<span class="woocommerce-Price-amount amount">' . $formatted_price . '</span>';
if ($ex_tax_label && wc_tax_enabled()) {
$return .= ' <small class="woocommerce-Price-taxLabel tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>';
}
return apply_filters('wc_price', $return, $price, $args);
}
开发者ID:coderkevin,项目名称:woocommerce,代码行数:23,代码来源:wc-formatting-functions.php
示例3: woocommerce_trim_zeros
/**
* @deprecated
*/
function woocommerce_trim_zeros($price)
{
return wc_trim_zeros($price);
}
开发者ID:nayemDevs,项目名称:woocommerce,代码行数:7,代码来源:wc-deprecated-functions.php
示例4: test_wc_trim_zeros
/**
* Test wc_trim_zeros().
*
* @since 2.2
*/
public function test_wc_trim_zeros()
{
$this->assertEquals('$1', wc_trim_zeros('$1.00'));
$this->assertEquals('$1.10', wc_trim_zeros('$1.10'));
}
开发者ID:jimlove7273,项目名称:woocommerce,代码行数:10,代码来源:functions.php
示例5: wc_price
/**
* Format the price with a currency symbol.
*
* @param float $price
* @param array $args (default: array())
* @return string
*/
function wc_price($price, $args = array())
{
extract(shortcode_atts(array('ex_tax_label' => '0'), $args));
$return = '';
$num_decimals = absint(get_option('woocommerce_price_num_decimals'));
$currency = isset($args['currency']) ? $args['currency'] : '';
$currency_symbol = get_woocommerce_currency_symbol($currency);
$decimal_sep = wp_specialchars_decode(stripslashes(get_option('woocommerce_price_decimal_sep')), ENT_QUOTES);
$thousands_sep = wp_specialchars_decode(stripslashes(get_option('woocommerce_price_thousand_sep')), ENT_QUOTES);
if ($price < 0) {
$price = $price * -1;
$negative = true;
} else {
$negative = false;
}
$price = apply_filters('raw_woocommerce_price', floatval($price));
$price = apply_filters('formatted_woocommerce_price', number_format($price, $num_decimals, $decimal_sep, $thousands_sep), $price, $num_decimals, $decimal_sep, $thousands_sep);
if (apply_filters('woocommerce_price_trim_zeros', false) && $num_decimals > 0) {
$price = wc_trim_zeros($price);
}
$formatted_price = ($negative ? '-' : '') . sprintf(get_woocommerce_price_format(), $currency_symbol, $price);
$return = '<span class="amount">' . $formatted_price . '</span>';
if ($ex_tax_label && get_option('woocommerce_calc_taxes') == 'yes') {
$return .= ' <small>' . WC()->countries->ex_tax_or_vat() . '</small>';
}
return apply_filters('wc_price', $return, $price, $args);
}
开发者ID:uwitec,项目名称:findgreatmaster,代码行数:34,代码来源:wc-formatting-functions.php
示例6: uni_cpo_get_formatted_price
function uni_cpo_get_formatted_price($sPrice)
{
$decimal_separator = wc_get_price_decimal_separator();
$thousand_separator = wc_get_price_thousand_separator();
$decimals = wc_get_price_decimals();
$price_format = get_woocommerce_price_format();
$negative = $sPrice < 0;
$sPrice = apply_filters('raw_woocommerce_price', floatval($negative ? $sPrice * -1 : $sPrice));
$sPrice = apply_filters('formatted_woocommerce_price', number_format($sPrice, $decimals, $decimal_separator, $thousand_separator), $sPrice, $decimals, $decimal_separator, $thousand_separator);
if (apply_filters('woocommerce_price_trim_zeros', false) && $decimals > 0) {
$sPrice = wc_trim_zeros($sPrice);
}
$formatted_price = ($negative ? '-' : '') . sprintf($price_format, get_woocommerce_currency_symbol(''), $sPrice);
return $formatted_price;
}
开发者ID:primus1989,项目名称:https---github.com-DataDesignSystems-drishtiq,代码行数:15,代码来源:uni-cpo.php
示例7: wc_price
/**
* Returns $price formatted with currency symbol and decimals, as
* configured within WooCommerce settings
*
* Annoyingly, WC doesn't seem to offer a function to format a price string
* without HTML tags, so this method is adapted from the core wc_price()
* function.
*
* @since 2.0
* @see wc_price()
* @param string $price the price
* @return string price formatted
*/
private function wc_price($price)
{
if (0 == $price) {
return __('Free!', WC_PDF_Product_Vouchers::TEXT_DOMAIN);
}
$return = '';
$num_decimals = absint(get_option('woocommerce_price_num_decimals'));
$currency_pos = get_option('woocommerce_currency_pos');
// Don't ask me how, but somehow this works for stuff like '€' when nothing else would
$currency_symbol = utf8_encode(iconv('UTF-8', 'windows-1252', html_entity_decode(get_woocommerce_currency_symbol(), ENT_QUOTES, "UTF-8")));
$decimal_sep = wp_specialchars_decode(stripslashes(get_option('woocommerce_price_decimal_sep')), ENT_QUOTES);
$thousands_sep = wp_specialchars_decode(stripslashes(get_option('woocommerce_price_thousand_sep')), ENT_QUOTES);
$price = apply_filters('raw_woocommerce_price', floatval($price));
$price = apply_filters('formatted_woocommerce_price', number_format($price, $num_decimals, $decimal_sep, $thousands_sep), $price, $num_decimals, $decimal_sep, $thousands_sep);
if (apply_filters('woocommerce_price_trim_zeros', true) && $num_decimals > 0) {
$price = wc_trim_zeros($price);
}
$return = sprintf(str_replace(' ', ' ', get_woocommerce_price_format()), $currency_symbol, $price);
return $return;
}
开发者ID:reti-senza-frontiere,项目名称:WP-Plugins,代码行数:33,代码来源:class-wc-voucher.php
示例8: get_composited_item_price_string_price
/**
* Used throughout the extension instead of 'wc_price'.
*
* @param double $price
* @return string
*/
public function get_composited_item_price_string_price($price, $args = array())
{
$return = '';
$num_decimals = $this->wc_option_price_num_decimals;
$currency = isset($args['currency']) ? $args['currency'] : '';
$currency_symbol = get_woocommerce_currency_symbol($currency);
$decimal_sep = $this->wc_option_price_decimal_sep;
$thousands_sep = $this->wc_option_price_thousand_sep;
$price = apply_filters('raw_woocommerce_price', floatval($price));
$price = apply_filters('formatted_woocommerce_price', number_format($price, $num_decimals, $decimal_sep, $thousands_sep), $price, $num_decimals, $decimal_sep, $thousands_sep);
if (apply_filters('woocommerce_price_trim_zeros', false) && $num_decimals > 0) {
$price = wc_trim_zeros($price);
}
$return = sprintf(get_woocommerce_price_format(), $currency_symbol, $price);
return $return;
}
开发者ID:ajay786singh,项目名称:viriditas-1,代码行数:22,代码来源:class-wc-cp-api.php
示例9: wc_crm_price_num_decimals
function wc_crm_price_num_decimals($summ)
{
$summ = (double) $summ;
$num_decimals = absint(get_option('woocommerce_price_num_decimals'));
$decimal_sep = wp_specialchars_decode(stripslashes(get_option('woocommerce_price_decimal_sep')), ENT_QUOTES);
$thousands_sep = wp_specialchars_decode(stripslashes(get_option('woocommerce_price_thousand_sep')), ENT_QUOTES);
if ($summ < 0) {
$summ = $summ * -1;
$negative = true;
} else {
$negative = false;
}
$summ = apply_filters('raw_woocommerce_price', floatval($summ));
$summ = apply_filters('formatted_woocommerce_price', number_format($summ, $num_decimals, $decimal_sep, $thousands_sep), $summ, $num_decimals, $decimal_sep, $thousands_sep);
if (apply_filters('woocommerce_price_trim_zeros', false) && $num_decimals > 0) {
$summ = wc_trim_zeros($summ);
}
return $summ;
}
开发者ID:daanbakker1995,项目名称:vanteun,代码行数:19,代码来源:core-functions.php
示例10: formatted_price
public static function formatted_price($price)
{
$num_decimals = absint(get_option('woocommerce_price_num_decimals'));
$currency = isset($args['currency']) ? $args['currency'] : '';
$currency_symbol = get_woocommerce_currency_symbol($currency);
$decimal_sep = get_option('woocommerce_price_decimal_sep');
$thousands_sep = get_option('woocommerce_price_thousand_sep');
$price = apply_filters('raw_woocommerce_price', floatval($price));
$price = apply_filters('formatted_woocommerce_price', number_format($price, $num_decimals, $decimal_sep, $thousands_sep), $price, $num_decimals, $decimal_sep, $thousands_sep);
if (apply_filters('woocommerce_price_trim_zeros', true) && $num_decimals > 0) {
$price = wc_trim_zeros($price);
}
$return = sprintf(get_woocommerce_price_format(), $currency_symbol, $price);
return $return;
}
开发者ID:galapas,项目名称:opentickets-community,代码行数:15,代码来源:pricing.class.php
示例11: yith_get_formatted_price
/**
* Format the price with a currency symbol.
*
* @param float $price
* @param array $args (default: array())
*
* @return string
*/
function yith_get_formatted_price($price, $args = array())
{
extract(apply_filters('wc_price_args', wp_parse_args($args, array('ex_tax_label' => false, 'currency' => '', 'decimal_separator' => wc_get_price_decimal_separator(), 'thousand_separator' => wc_get_price_thousand_separator(), 'decimals' => wc_get_price_decimals(), 'price_format' => get_woocommerce_price_format()))));
$negative = $price < 0;
$price = apply_filters('raw_woocommerce_price', floatval($negative ? $price * -1 : $price));
$price = apply_filters('formatted_woocommerce_price', number_format($price, $decimals, $decimal_separator, $thousand_separator), $price, $decimals, $decimal_separator, $thousand_separator);
if (apply_filters('woocommerce_price_trim_zeros', false) && $decimals > 0) {
$price = wc_trim_zeros($price);
}
$formatted_price = ($negative ? '-' : '') . sprintf($price_format, get_woocommerce_currency_symbol($currency), $price);
$return = $formatted_price;
return apply_filters('wc_price', $return, $price, $args);
}
开发者ID:yarwalker,项目名称:ecobyt,代码行数:21,代码来源:yit-functions.php
示例12: format_price
public static function format_price($price)
{
$num_decimals = absint(get_option('woocommerce_price_num_decimals'));
$decimal_sep = wp_specialchars_decode(stripslashes(get_option('woocommerce_price_decimal_sep')), ENT_QUOTES);
$thousands_sep = wp_specialchars_decode(stripslashes(get_option('woocommerce_price_thousand_sep')), ENT_QUOTES);
if ($price != "") {
$price = apply_filters('raw_woocommerce_price', floatval($price));
$price = apply_filters('formatted_woocommerce_price', number_format($price, $num_decimals, $decimal_sep, $thousands_sep), $price, $num_decimals, $decimal_sep, $thousands_sep);
if (apply_filters('woocommerce_price_trim_zeros', false) && $num_decimals > 0) {
$price = wc_trim_zeros($price);
}
}
return $price;
}
开发者ID:slavic18,项目名称:cats,代码行数:14,代码来源:class-wc-name-your-price-helpers.php
注:本文中的wc_trim_zeros函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论