Created
April 8, 2020 13:40
-
-
Save dangoodman/0c8aba61b396fa1bcedf15fea8d04acd to your computer and use it in GitHub Desktop.
WooCommerce: round up shipping prices
This file contains 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