wc_trim_zeros

Trim trailing zeros off prices.

Description

(string) wc_trim_zeros( (mixed) $price ); 

Returns (string)

Parameters (1)

0. $price (mixed)
The price.

Usage

  1. if ( !function_exists( 'wc_trim_zeros' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-formatting-functions.php'; 
  3.  
  4. // The price. 
  5. $price = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_trim_zeros($price); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-formatting-functions.php  
  1. function wc_trim_zeros( $price ) { 
  2. return preg_replace( '/' . preg_quote( wc_get_price_decimal_separator(), '/' ) . '0++$/', '', $price );