Skip to content

Instantly share code, notes, and snippets.

@xadapter xadapter/functions.php
Last active Apr 19, 2018

Embed
What would you like to do?
Snippet to add invoice number in fedex label. Support for WooCommerce PDF Invoices By Bas Elbers. Fedex plugin - https://www.xadapter.com/product/woocommerce-fedex-shipping-plugin-with-print-label/
/**
* Snippet to add invoice number in fedex label. Support for WooCommerce PDF Invoices By Bas Elbers.
* Created at : 18 April 2018
* Updated at : 18 April 2018
* Xadapter Plugins : https://www.xadapter.com/shop/
* Gist Link : https://gist.github.com/xadapter/79d628b412a2c7f9b3cbbcee419239a4
*/
add_filter( 'wf_fedex_request', 'xa_fedex_add_invoice_number', 10, 2 );
if( ! function_exists('xa_fedex_add_invoice_number') ) {
function xa_fedex_add_invoice_number( $request, $order ) {
$invoice_number = $order->get_meta('_bewpi_invoice_number'); // _bewpi_invoice_number to support WooCommerce PDF Invoices By Bas Elbers
if( ! empty($invoice_number) ) {
foreach( $request['RequestedShipment']['RequestedPackageLineItems'] as $key => $request_package_line_item ) {
$request['RequestedShipment']['RequestedPackageLineItems'][$key]['CustomerReferences'][] = array(
'CustomerReferenceType' => 'INVOICE_NUMBER',
'Value' => $invoice_number,
);
}
}
return $request;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.