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; | |
} |
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. | |
// Cancel sanitizing for all shipping option labels starting with 'HTML:'. | |
remove_filter('woocommerce_shipping_rate_label', 'sanitize_text_field'); | |
add_filter('woocommerce_shipping_rate_label', function($label) { | |
if (substr_compare($label, 'HTML:', 0, 5) === 0) { | |
$label = ltrim(substr($label, 5)); | |
} |
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. | |
// Change the free shipping label to 'Free shipping'. | |
add_filter('woocommerce_cart_shipping_method_full_label', static function ($label, $method) { | |
if ($method->cost == 0) { | |
$label = 'Free shipping'; | |
} | |
return $label; | |
}, 10, 2); |
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. | |
// "Squashes" all delivery options into a single one. | |
// 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) { | |
if (count($rates) > 1) { | |
$firstRate = null; | |
$firstRateId = null; | |
foreach ($rates as $id => $rate) { |
OlderNewer