we wish to round all prices decimals, for example, $3.22 > $3 and $3.59 > $4. Not only on display price but also the calculation during checkout.
We found a really good solution from:
How to round WooCommerce product prices to the tens digit place?
and modify the code to be:
add_filter( 'raw_woocommerce_price', 'round_price_product', 1000, 1 );
add_filter( 'woocommerce_product_get_price', 'round_price_product', 1000, 1 );
add_filter( 'woocommerce_product_variation_get_price', 'round_price_product', 1000, 1 );
function round_price_product( $price ){
// Return rounded price
return round( $price);
}
It works well in front end. All prices are integer now, and calculation is correct. However, it crushes down the backend product list page. And of course we cannot create/edit products too.
Any idea? Any input is appreciated.
Vanna Miss is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1