Title: rounding prices
Last modified: August 30, 2016

---

# rounding prices

 *  Resolved [utoSeb](https://wordpress.org/support/users/utoseb/)
 * (@utoseb)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/rounding-prices/)
 * I’m having the following issue when I’m trying to round up prices in WC:
    Product
   A has ‘160.4839’ as a regular price. I’m adding tax on top of this (which is 
   24%). The total price that should be shown (including tax) should 199.00. Product
   B has ‘96.7000’ as a regular price. The tax on top of that is 24%. The price 
   that should be shown is 120.00 (currently it’s 119.90 what it’s being displayed).
   And this is my round function located in functions.php
 *     ```
       add_filter( 'woocommerce_get_price_including_tax', 'round_price_product', 10, 1 );
       add_filter('wc_cart_totals_subtotal_html', 'round_price_product', 10, 1 );
       add_filter( 'woocommerce_get_price', 'round_price_product', 10, 1);
   
       function round_price_product( $price ){
           return round($price);
       }
       ```
   
 * I do realise that my problem lies somewhere with the decimals, but I can’t get
   round() right. How could I achieve the above result? It’s been driving me mental.
 * Thanks!
 * [https://wordpress.org/plugins/woocommerce/](https://wordpress.org/plugins/woocommerce/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Contributor [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * (@mikejolley)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/rounding-prices/#post-6445001)
 * Adding decimals like that is going to cause rounding issues down the line.
 * If prices must be exactly 199 for example, you could define prices including 
   tax. It really depends on your needs and location.
 *  Thread Starter [utoSeb](https://wordpress.org/support/users/utoseb/)
 * (@utoseb)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/rounding-prices/#post-6445212)
 * [@mike](https://wordpress.org/support/users/mike/) Jolley – thanks for the tip.
   I’ve removed decimals all together. Ugly things those are
 *  [marahman.b2b](https://wordpress.org/support/users/marahmanb2b/)
 * (@marahmanb2b)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/rounding-prices/#post-6445227)
 * Hi
 * I used this script in function.php bottom its hiding ‘Sale price’ on all pages.
 * how to overcome with this issue.
 *  [marahman.b2b](https://wordpress.org/support/users/marahmanb2b/)
 * (@marahmanb2b)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/rounding-prices/#post-6445228)
 * currently below scripts running in function.php bottom is any one of it casing
   resulting Sale Price getting hide.
 * /*
    * Swop the ‘Free!’ price notice and hide the cart with ‘POA’ in WooCommerce*/
   add_filter( ‘woocommerce_variable_free_price_html’, ‘hide_free_price_notice’ );
   add_filter( ‘woocommerce_free_price_html’, ‘hide_free_price_notice’ ); add_filter(‘
   woocommerce_variation_free_price_html’, ‘hide_free_price_notice’ );
 * function hide_free_price_notice( $price ) {
    remove_action( ‘woocommerce_single_product_summary’,‘
   woocommerce_template_single_add_to_cart’, 30 ); return ‘Call for Price’; }
 * /**
    * Adds product SKUs above the “Add to Cart” buttons * Tutorial: [http://www.skyverge.com/blog/add-information-to-woocommerce-shop-page/](http://www.skyverge.com/blog/add-information-to-woocommerce-shop-page/)**/
   function skyverge_shop_display_skus() {
 *  global $product;
 *  if ( $product->get_sku() ) {
    echo ‘<div class=”product-meta”>SKU: ‘ . $product-
   >get_sku() . ‘</div>’; } } add_action( ‘woocommerce_after_shop_loop_item’, ‘skyverge_shop_display_skus’,
   9 );
 * // Add save percent next to sale item prices.
    add_filter( ‘woocommerce_sale_price_html’,‘
   woocommerce_custom_sales_price’, 10, 2 ); function woocommerce_custom_sales_price(
   $price, $product ) { $percentage = round( ( ( $product->regular_price – $product-
   >sale_price ) / $product->regular_price ) * 100 ); return $price . sprintf( __(‘
   Save %s’, ‘woocommerce’ ), $percentage . ‘%’ ); }
 *  [marahman.b2b](https://wordpress.org/support/users/marahmanb2b/)
 * (@marahmanb2b)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/rounding-prices/#post-6445229)
 * Hi Friends,
 * need you expert help on my above issue

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘rounding prices’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * ["round](https://wordpress.org/support/topic-tag/round/)
 * [float](https://wordpress.org/support/topic-tag/float/)
 * [price](https://wordpress.org/support/topic-tag/price/)

 * 5 replies
 * 3 participants
 * Last reply from: [marahman.b2b](https://wordpress.org/support/users/marahmanb2b/)
 * Last activity: [10 years, 2 months ago](https://wordpress.org/support/topic/rounding-prices/#post-6445229)
 * Status: resolved