Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to trim zeros from round decimal prices in WooCommerce. See
// Need to trim zeros from a price on the fly?
$price = 49.00; // Can be numeric or a string.
$price = wc_trim_zeros( $price ); // === '49'
// If a WooCommerce price is a full dollar value, trim the
// decimal & any trailing zeros.
// e.g; $49.00 will display as just $49
add_filter( 'woocommerce_price_trim_zeros', '__return_true' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment