/** * Returns the price given the arguments in add_theme_support for 'app-price-format' * Note: if hide_decimals is turned on, the amount will be rounded. * * @param int $price The numerical value to format * @param string $override_currency The currency the value is in (defaults to 'currency_default') * @param string $override_format The format the value is in (defaults to 'currency_identifier') * @return string The formatted price */ function appthemes_get_price($price, $override_currency = '', $override_identifier = '') { $format_args = appthemes_price_format_get_args(); $decimals = $format_args['hide_decimals'] ? 0 : 2; $base_price = number_format($price, $decimals, $format_args['decimal_separator'], $format_args['thousands_separator']); $currency_code = empty($override_currency) ? $format_args['currency_default'] : $override_currency; $currency_identifier = empty($override_identifier) ? $format_args['currency_identifier'] : $override_identifier; $position = $format_args['currency_position']; $identifier = APP_Currencies::get_currency($currency_code, $currency_identifier); return _appthemes_format_display_price($base_price, $identifier, $position); }
function cp_pos_currency($price_out, $price_type = '') { global $post, $cp_options; $price = $price_out; if ($price_type == 'ad') { $curr_symbol = $cp_options->curr_symbol; } else { $curr_symbol = $price_type; } //if ad have custom currency, display it instead of default one if ($price_type == 'ad' && isset($post) && is_object($post)) { $custom_curr = get_post_meta($post->ID, 'cp_currency', true); if (!empty($custom_curr)) { $curr_symbol = $custom_curr; } } //possition the currency symbol if (current_theme_supports('app-price-format')) { $price_out = _appthemes_format_display_price($price_out, $curr_symbol, $cp_options->currency_position); } else { $price_out = $price_out . ' ' . $curr_symbol; } return apply_filters('cp_currency_position', $price_out, $price, $curr_symbol, $price_type); }