Last active
July 16, 2019 09:36
Star
You must be signed in to star a gist
[USPS Shipping Method] To change the USPS package to envelope so dimensions are fixed, add this to your theme's functions.php file:
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
/** | |
* USPS 4.0 introduced the ability for envelopes to be flexible you can disable this with this function | |
* Simply set the type to 'envelope' instead of 'package' for any of the flat rate services that USPS lists as envelopes | |
*/ | |
add_filter( 'wc_usps_flat_rate_boxes', 'custom_usps_flat_rate_boxes' ); | |
function custom_usps_flat_rate_boxes( $flat_rate_boxes ) { | |
// Priority Mail Express Envelopes | |
$flat_rate_boxes["d13"]["type"] = 'envelope'; | |
$flat_rate_boxes["d30"]["type"] = 'envelope'; | |
$flat_rate_boxes["d55"]["type"] = 'envelope'; | |
$flat_rate_boxes["d63"]["type"] = 'envelope'; | |
$flat_rate_boxes["d98"]["type"] = 'envelope'; | |
// Priority Mail Envelopes | |
$flat_rate_boxes["d16"]["type"] = 'envelope'; | |
$flat_rate_boxes["d29"]["type"] = 'envelope'; | |
$flat_rate_boxes["d38"]["type"] = 'envelope'; | |
$flat_rate_boxes["d40"]["type"] = 'envelope'; | |
$flat_rate_boxes["d42"]["type"] = 'envelope'; | |
$flat_rate_boxes["d44"]["type"] = 'envelope'; | |
// International Priority Mail Express | |
$flat_rate_boxes["i13"]["type"] = 'envelope'; | |
$flat_rate_boxes["130"]["type"] = 'envelope'; | |
// International Priority Mail | |
$flat_rate_boxes["i8"]["type"] = 'envelope'; | |
$flat_rate_boxes["i29"]["type"] = 'envelope'; | |
return $flat_rate_boxes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment