Created
January 4, 2018 15:05
-
-
Save dangoodman/72c3d74eec2d7e235b1e98c9688f28a0 to your computer and use it in GitHub Desktop.
WooCommerce: cut shipping option ids if they exceed 50-chars length
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. | |
// Cut shipping option ids if they exceed 50-chars length. | |
add_filter('woocommerce_package_rates', function ($rates) { | |
$shortened = array(); | |
foreach ($rates as $rate_id => $rate) { | |
$rate_id = substr($rate_id, 0, 50); | |
$rate->id = $rate_id; | |
$shortened[$rate_id] = $rate; | |
} | |
return $shortened; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment