Skip to content

Instantly share code, notes, and snippets.

@Nishadup
Last active October 24, 2017 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Nishadup/67af2e4fbacd1774c62cff5919d58aeb to your computer and use it in GitHub Desktop.
Save Nishadup/67af2e4fbacd1774c62cff5919d58aeb to your computer and use it in GitHub Desktop.
Round to weight and dimensions nearest upper integer if destination country is Switzerland. Work with WooCommerce FedEx plugin https://www.xadapter.com/product/woocommerce-fedex-shipping-plugin-with-print-label/
add_filter('wf_fedex_request', 'remove_fraction_for_switz', 10, 2);
function remove_fraction_for_switz($request, $order) {
if ($request['RequestedShipment']['Shipper']['Address']['CountryCode'] == 'CH') {
$request['RequestedShipment']['TotalWeight']['Value'] = ceil($request['RequestedShipment']['TotalWeight']['Value']);
foreach ($request['RequestedShipment']['RequestedPackageLineItems'] as $key => &$value) {
if( isset( $value['Dimensions'] ) ){
$value['Dimensions']['Length'] = ceil( $value['Dimensions']['Length'] );
$value['Dimensions']['Width'] = ceil( $value['Dimensions']['Width'] );
$value['Dimensions']['Height'] = ceil( $value['Dimensions']['Height'] );
$value['Weight']['Value'] = ceil( $value['Weight']['Value'] );
}
}
}
return $request;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment