Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[USPS Shipping Method] To change the USPS package to envelope so dimensions are fixed, add this to your theme's functions.php file:
/**
* 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
You can’t perform that action at this time.