From ceff57323cdd0627bb51c4d31df6b0084cfddb9f Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Fri, 27 Jan 2012 15:00:12 +0000 Subject: [PATCH] trim trailing zero function --- woocommerce-core-functions.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/woocommerce-core-functions.php b/woocommerce-core-functions.php index 1c9dee81b04..ebc0ea99602 100644 --- a/woocommerce-core-functions.php +++ b/woocommerce-core-functions.php @@ -162,7 +162,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) : - $price = preg_replace('/'.preg_quote(get_option('woocommerce_price_decimal_sep'), '/').'0++$/', '', $price); + $price = woocommerce_trim_zeros($price); endif; switch ($currency_pos) : @@ -185,6 +185,13 @@ function woocommerce_price( $price, $args = array() ) { return $return; } +/** + * Trim trailing zeros + **/ +function woocommerce_trim_zeros( $price ) { + return rtrim(rtrim($price, '0'), '.'); +} + /** * Clean variables **/