I am using following function to round up the price in wordpress..
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 );
}
The above function round up the prices like
If price Rs 999.85/- to Rs 1000/-
If price Rs 999.15/- to Rs 1000/-
I want round up the price like below..
If Price Rs 999.55/- to Rs 1000/-
If the price Rs 999.15/- to Rs 999/-
How to do this…?
You can achieve the same by simply using the php
round()
function as like this :Hope it works for you.