Skip to content

Instantly share code, notes, and snippets.

@woogists
Last active July 16, 2019 09:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save woogists/244477cb47b5b5ee1666a5f330a3977b to your computer and use it in GitHub Desktop.
[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