Simplified price_trim_zeros handling

This commit is contained in:
Geert De Deckere 2012-01-22 10:38:50 +01:00
parent 7b943ecfb8
commit fbcc8807d7
1 changed files with 1 additions and 3 deletions

View File

@ -159,9 +159,7 @@ function woocommerce_price( $price, $args = array() ) {
$price = number_format( (double) $price, $num_decimals, get_option('woocommerce_price_decimal_sep'), get_option('woocommerce_price_thousand_sep') );
if (get_option('woocommerce_price_trim_zeros')=='yes' && $num_decimals>0) :
$trimmed_price = rtrim(rtrim($price, '0'), get_option('woocommerce_price_decimal_sep'));
$after_decimal = explode(get_option('woocommerce_price_decimal_sep'), $trimmed_price);
if (!isset($after_decimal[1]) || (isset($after_decimal[1]) && (strlen($after_decimal[1]) == 0 && strlen($after_decimal[1]) == $num_decimals))) $price = $trimmed_price;
$price = preg_replace('/'.preg_quote(get_option('woocommerce_price_decimal_sep'), '/').'0++$/', '', $price);
endif;
switch ($currency_pos) :