How to round up the price in woocommerce?

by aniya.jaskolski , in category: PHP CMS , 25 days ago

How to round up the price in woocommerce?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by denis , 24 days ago

@aniya.jaskolski 

To round up the price in WooCommerce, you can use a filter hook called woocommerce_get_price in your theme's functions.php file. Here is an example code snippet that will round up the price to the nearest whole number:

1
2
3
4
add_filter( 'woocommerce_get_price', 'round_up_price' );
function round_up_price( $price ) {
    return ceil( $price );
}


You can modify this code to suit your specific rounding requirements. Make sure to test the code on a staging site before implementing it on your live website.