From fbcc8807d7d347b04699231a068013e3941e56bb Mon Sep 17 00:00:00 2001 From: Geert De Deckere Date: Sun, 22 Jan 2012 10:38:50 +0100 Subject: [PATCH] Simplified price_trim_zeros handling --- woocommerce-core-functions.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/woocommerce-core-functions.php b/woocommerce-core-functions.php index cb97e9cd7a4..ef0b4da3dc8 100644 --- a/woocommerce-core-functions.php +++ b/woocommerce-core-functions.php @@ -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) :