WooCommerce – Disply prices with two decimal zeroes as (,-) instead of (,00)

I had a project, where prices had to be displayed with ,- instead of two decimal zeroes ,00. (99,- instead of 99,00).

In WooCommerce you can do this really simple.

Just put this code in your theme's functions.php file:

function remove_zeroes_from_price($price) {
	$price = str_replace(',00', ',-', $price);
	return $price;
}
add_filter('woocommerce_get_price_html', 'remove_zeroes_from_price');
ms@morningtrain.dk'

Martin Schadegg Rasch Jensen

  • We Inspire Ideas

    How do i get it to display like that for the entire website, such as in the amount sections and checkout page?

    • You have to find the filters for the different places the price is displayed, and run this funciton. Take a look on the WooCommerce docs: http://docs.woothemes.com/wc-apidocs/ and the filters docs: http://woodocs.wpengine.com/document/hooks/.
      One filter you can try is: woocommerce_cart_totals_order_total_html
      Add the following below the code: add_filter(‘woocommerce_cart_totals_order_total_html’, ‘remove_zeroes_from_price’);
      I have not testet it, but it should work, I have not tested, if you need to add some other filters too.