trim trailing zero function

This commit is contained in:
Mike Jolley 2012-01-27 15:00:12 +00:00
parent 89a226a895
commit ceff57323c
1 changed files with 8 additions and 1 deletions

View File

@ -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
**/