Skip to content

Instantly share code, notes, and snippets.

@WooForce
Created April 13, 2016 13:49
Show Gist options
  • Save WooForce/824b8347fba63cb28cb160305eca774c to your computer and use it in GitHub Desktop.
Save WooForce/824b8347fba63cb28cb160305eca774c to your computer and use it in GitHub Desktop.
FedEx - Change product name and description while label printing.
add_filter('wf_fedex_request','wf_fedex_label_custom_product_name_request_callback', 10, 2 );
function wf_fedex_label_custom_product_name_request_callback($request, $order){
$product_name = 'Book'; //Type here a product name it'll come as name of all products, Don't leave this blank or white space
$product_description = 'Book'; //Description, This will come for all products, Don't leave this blank or white space
$commodities = isset( $request['RequestedShipment']['CustomsClearanceDetail']['Commodities'] ) ? $request['RequestedShipment']['CustomsClearanceDetail']['Commodities'] : '';
if($commodities != '' ){
foreach ($commodities as $key => $commodity) {
$request['RequestedShipment']['CustomsClearanceDetail']['Commodities'][$key]['Name'] = sanitize_title( $product_name );
$request['RequestedShipment']['CustomsClearanceDetail']['Commodities'][$key]['Description'] = sanitize_title( $product_description );
}
}
return $request;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment