/**
 * Format the price with a currency symbol.
 *
 * @access public
 * @param float $price
 * @param array $args (default: array())
 * @return string
 */
function woocommerce_price($price, $args = array())
{
    global $woocommerce;
    extract(shortcode_atts(array('ex_tax_label' => '0'), $args));
    $return = '';
    $num_decimals = (int) get_option('woocommerce_price_num_decimals');
    $currency_pos = get_option('woocommerce_currency_pos');
    $currency_symbol = get_woocommerce_currency_symbol();
    $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', (double) $price);
    $price = number_format($price, $num_decimals, $decimal_sep, $thousands_sep);
    if (get_option('woocommerce_price_trim_zeros') == 'yes' && $num_decimals > 0) {
        $price = woocommerce_trim_zeros($price);
    }
    $return = '<span class="amount">' . sprintf(get_woocommerce_price_format(), $currency_symbol, $price) . '</span>';
    if ($ex_tax_label && get_option('woocommerce_calc_taxes') == 'yes') {
        $return .= ' <small>' . $woocommerce->countries->ex_tax_or_vat() . '</small>';
    }
    return $return;
}
/**
 * Price Formatting Helper
 **/
function woocommerce_price($price, $args = array())
{
    global $woocommerce;
    extract(shortcode_atts(array('ex_tax_label' => '0'), $args));
    $return = '';
    $num_decimals = (int) get_option('woocommerce_price_num_decimals');
    $currency_pos = get_option('woocommerce_currency_pos');
    $currency_symbol = get_woocommerce_currency_symbol();
    $price = apply_filters('raw_woocommerce_price', (double) $price);
    $price = number_format($price, $num_decimals, stripslashes(get_option('woocommerce_price_decimal_sep')), stripslashes(get_option('woocommerce_price_thousand_sep')));
    if (get_option('woocommerce_price_trim_zeros') == 'yes' && $num_decimals > 0) {
        $price = woocommerce_trim_zeros($price);
    }
    switch ($currency_pos) {
        case 'left':
            $return = '<span class="amount">' . $currency_symbol . $price . '</span>';
            break;
        case 'right':
            $return = '<span class="amount">' . $price . $currency_symbol . '</span>';
            break;
        case 'left_space':
            $return = '<span class="amount">' . $currency_symbol . '&nbsp;' . $price . '</span>';
            break;
        case 'right_space':
            $return = '<span class="amount">' . $price . '&nbsp;' . $currency_symbol . '</span>';
            break;
    }
    if ($ex_tax_label && get_option('woocommerce_calc_taxes') == 'yes') {
        $return .= ' <small>' . $woocommerce->countries->ex_tax_or_vat() . '</small>';
    }
    return $return;
}
Exemplo n.º 3
0
function vtprd_format_money_element($price)
{
    //from woocommerce/woocommerce-core-function.php   function woocommerce_price
    $return = '';
    $num_decimals = (int) get_option('woocommerce_price_num_decimals');
    $currency_pos = get_option('woocommerce_currency_pos');
    $currency_symbol = get_woocommerce_currency_symbol();
    $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', (double) $price);
    $price = number_format($price, $num_decimals, $decimal_sep, $thousands_sep);
    if (get_option('woocommerce_price_trim_zeros') == 'yes' && $num_decimals > 0) {
        $price = woocommerce_trim_zeros($price);
    }
    //$return = '<span class="amount">' . sprintf( get_woocommerce_price_format(), $currency_symbol, $price ) . '</span>';
    $formatted = sprintf(get_woocommerce_price_format(), $currency_symbol, $price);
    return $formatted;
}
function vtmin_format_money_element($price)
{
    //from woocommerce/woocommerce-core-function.php   function woocommerce_price
    $return = '';
    $num_decimals = (int) get_option('woocommerce_price_num_decimals');
    $currency_pos = get_option('woocommerce_currency_pos');
    $currency_symbol = get_woocommerce_currency_symbol();
    $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', (double) $price);
    $price = number_format($price, $num_decimals, $decimal_sep, $thousands_sep);
    if (get_option('woocommerce_price_trim_zeros') == 'yes' && $num_decimals > 0) {
        $price = woocommerce_trim_zeros($price);
    }
    //$return = '<span class="amount">' . sprintf( get_woocommerce_price_format(), $currency_symbol, $price ) . '</span>';
    $current_version = WOOCOMMERCE_VERSION;
    if (version_compare(strval('2'), strval($current_version), '>') == 1) {
        //'==1' = 2nd value is lower
        $formatted = number_format($price, $num_decimals, stripslashes(get_option('woocommerce_price_decimal_sep')), stripslashes(get_option('woocommerce_price_thousand_sep')));
        $formatted = $currency_symbol . $formatted;
    } else {
        $formatted = sprintf(get_woocommerce_price_format(), $currency_symbol, $price);
    }
    return $formatted;
}
 /**
  * Trim trailing zeros off prices.
  *
  * @since 2.0.1
  * @param string $price the price
  * @return string price with zeroes trimmed
  */
 public static function wc_trim_zeroes($price)
 {
     if (self::is_wc_version_gte_2_1()) {
         return wc_trim_zeroes($price);
     } else {
         return woocommerce_trim_zeros($price);
     }
 }
function woocommerce_bulk_variations_get_price($price, $args = array())
{
    global $woocommerce;
    extract(shortcode_atts(array('ex_tax_label' => '0'), $args));
    $return = '';
    $num_decimals = (int) get_option('woocommerce_price_num_decimals');
    $currency_pos = get_option('woocommerce_currency_pos');
    $currency_symbol = get_woocommerce_currency_symbol();
    $price = apply_filters('raw_woocommerce_price', (double) $price);
    $price = number_format($price, $num_decimals, stripslashes(get_option('woocommerce_price_decimal_sep')), stripslashes(get_option('woocommerce_price_thousand_sep')));
    if (get_option('woocommerce_price_trim_zeros') == 'yes' && $num_decimals > 0) {
        $price = woocommerce_trim_zeros($price);
    }
    switch ($currency_pos) {
        case 'left':
            $return = $currency_symbol . $price;
            break;
        case 'right':
            $return = $price . $currency_symbol;
            break;
        case 'left_space':
            $return = $currency_symbol . '&nbsp;' . $price . '';
            break;
        case 'right_space':
            $return = $price . '&nbsp;' . $currency_symbol . '';
            break;
    }
    return $return;
}