-
-
Save dariodev/ec4a337abd98ce174c67e652f304b528 to your computer and use it in GitHub Desktop.
WooCommerce: round up shipping prices
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Paste everything below this line to your child-theme's functions.php file. | |
// Rounds up all shipping rates by the $roundUpBy value. | |
// After pasting this snippet, reset the WooCommerce shipping cache, e.g. add an item to the cart. | |
add_filter('woocommerce_package_rates', function ($rates, $package) { | |
$roundUpBy = 5; | |
foreach ($rates as $rate) { | |
$rate->cost = ceil($rate->cost / $roundUpBy) * $roundUpBy; | |
} | |
return $rates; | |
}, 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment