-
-
Save xadapter/2fa2f7704db1124c0d4916d53a79fb9b to your computer and use it in GitHub Desktop.
Snippet to round off the weight and dimensions nearest to the upper integer if destination country is Switzerland. WooCommerce FedEx Shipping Plugin: https://www.pluginhive.com/product/woocommerce-fedex-shipping-plugin-with-print-label/
This file contains 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