コード例 #1
0
ファイル: index.php プロジェクト: Inteleck/hwc
 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);
 }
コード例 #2
0
/**
 * 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);
}
コード例 #3
0
/**
 * @deprecated
 */
function woocommerce_trim_zeros($price)
{
    return wc_trim_zeros($price);
}
コード例 #4
0
ファイル: functions.php プロジェクト: jimlove7273/woocommerce
 /**
  * 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'));
 }
コード例 #5
0
/**
 * 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);
}
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;
}
コード例 #7
0
 /**
  * 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 '&euro;' 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('&nbsp;', ' ', get_woocommerce_price_format()), $currency_symbol, $price);
     return $return;
 }
コード例 #8
0
 /**
  * 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;
 }
コード例 #9
0
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;
}
コード例 #10
0
 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;
 }
コード例 #11
0
ファイル: yit-functions.php プロジェクト: yarwalker/ecobyt
 /**
  * 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);
 }
コード例 #12
0
 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;
 }