Last active
October 24, 2017 14:40
-
-
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/
This file contains hidden or 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
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