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.phpadd_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!
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘rounding prices’ is closed to new replies.