Skip to content

Instantly share code, notes, and snippets.

@varun-pluginhive
Created November 13, 2018 09:15
Show Gist options
  • Select an option

  • Save varun-pluginhive/42b90d1a70c8f85128b417ee5ebb99bf to your computer and use it in GitHub Desktop.

Select an option

Save varun-pluginhive/42b90d1a70c8f85128b417ee5ebb99bf to your computer and use it in GitHub Desktop.
Snippet to provide minimum package weight in FedEx Rate Request. WooCommerce FedEx Shipping Plugin with Print Label - https://www.pluginhive.com/product/woocommerce-fedex-shipping-plugin-with-print-label/
/**
* Snippet to provide minimum package weight in FedEx Rate Request.
* Created at : 13 Nov 2018
* Updated at : 13 Nov 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/varun-pluginhive/42b90d1a70c8f85128b417ee5ebb99bf
*/
add_filter( 'xa_fedex_rate_request', function($request){
$packaging_types = array( 'FEDEX_ENVELOPE' ); // Packaging Type
$min_weight = .1; // Minimum Weight
$packaging_type = $request['RequestedShipment']['PackagingType'];
$weight = $request['RequestedShipment']['RequestedPackageLineItems'];
if( ! empty($packaging_type) && in_array( $packaging_type, $packaging_types ) ) {
foreach( $request['RequestedShipment']['RequestedPackageLineItems'] as &$line_items ) {
if( $line_items['Weight']['Value'] < $min_weight ) {
$line_items['Weight']['Value'] = $min_weight;
}
}
}
return $request;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment