How to round a price in Wordpress?

I am using the woocommerce plugin version 2.2.8 for my e-commerce site. Product prices on my site look like (Rs 880.64 / -). I need to round this price to Rs 881 / -.

Is there any way to do this ?? For example: Product1 = 880.64 rupees (including tax rate). It should be converted to the nearest decimal value.

+4
source share
1 answer

You can try this on your topic functions.phpwithout changing your data:

add_filter( 'woocommerce_get_price_excluding_tax', 'round_price_product', 10, 1 );
add_filter( 'woocommerce_get_price_including_tax', 'round_price_product', 10, 1 );
add_filter( 'woocommerce_tax_round', 'round_price_product', 10, 1);
add_filter( 'woocommerce_get_price', 'round_price_product', 10, 1);

function round_price_product( $price ){
    // Return rounded price
    return ceil( $price );
}
+3
source

All Articles