Home / Blog / WooCommerce
,

Remove decimals from Product prices in WooCommerce

Under General Settings in WooCommerce Settings screen, you will find options to set your store Currency, Currency position, Decimal separator and Number of decimals for your store. Here, Number of decimals lets you choose the number of digits to appear after the decimal separator.

Based on the selected option, it will display prices throughout your website with decimals (like $121.00). To remove decimals from every price, set Number of decimals to 0 in WooCommerce > Settings > General.

If you only want to hide a trailing .00, add the code below to the functions.php file of your theme. It shows $121.00 as $121, while a price with cents, such as $121.50, keeps its decimals.

add_filter( 'woocommerce_price_trim_zeros', '__return_true' );

Want this checked on your own site? See Exivon Tech’s Website & E-commerce Audit.

Dhiren Patel

Principal Full-Stack Engineer · Founder, Exivon Tech

I’ve built and run enterprise web platforms and e-commerce for 13 years, and I built ShieldScope, a free WordPress security scanner.

8 responses to “Remove decimals from Product prices in WooCommerce”

  1. If you want decimal but don’t want to show .00 values, then this function can be used to trim the zero values.

    add_filter( ‘woocommerce_price_trim_zeros’, ‘__return_true’ );

    Add this into the functions.php.

    1. Dhiren Patel

      Thanks Deb.
      This will be helpful.

  2. Just what i was looking for, thank you!

  3. james

    it worked for me thank you

  4. Richard

    thank you!

  5. SALAM

    THANK YOU

  6. Thanks. I added the code to a client site, but after a customer use a coupon code, the total price has 2 decimals. See image: https://trenza.se/wp-content/uploads/2022/03/code-tack15.jpg

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.