Created
April 3, 2018 14:56
-
-
Save Nishadup/cca7062979718eaeba2c315e4ea20c64 to your computer and use it in GitHub Desktop.
Code snippet to limit insured amount to 100 in the cart with Xadapter FedEx plugin https://www.xadapter.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_calculate_shipping_request', 'modify_fedex_request', 10, 2); | |
function modify_fedex_request($fedex_requests, $fedex_packages){ | |
$insurance_amount = 100; // New Insurance amount | |
foreach ($fedex_requests as $req_no => &$request) { | |
if( isset($request['RequestedShipment']['TotalInsuredValue']['Amount']) ) { | |
$count = 0; | |
foreach( $request['RequestedShipment']['RequestedPackageLineItems'] as $key => $item ) { | |
$request['RequestedShipment']['RequestedPackageLineItems'][$key]['InsuredValue']['Amount'] = $insurance_amount; | |
$count++; | |
} | |
$request['RequestedShipment']['TotalInsuredValue']['Amount'] = $insurance_amount * $count; | |
} | |
} | |
return $fedex_requests; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment