Last active
March 13, 2017 14:12
-
-
Save xadapter/61e5445dfd8ff9f7913f9ce29907bfbf to your computer and use it in GitHub Desktop.
Alter UPS Order XML Export Data with Order/Coupon/Subscription import export plugin
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
function alter_ups_order_xml_export_data( $order_details ) { | |
foreach ($order_details as $key => $value) { | |
$order_details[$key]['Shipment']['ShipFrom']['UPSAccountNumber'] = 'xxxxxx'; // UPS Account Number | |
$order_details[$key]['Shipment']['ShipmentInformation']['ServiceType'] = 'GND'; // UPS ServiceType | |
$orderID = $order_details[$key]['Shipment']['ShipmentKey']; | |
$order = new WC_Order($orderID); | |
$coupons_list = ' CouponCode:'; | |
foreach( $order->get_used_coupons() as $coupon) { | |
$coupons_list .= $coupon.','; | |
} | |
$order_details[$key]['Shipment']['Packages']['Package']['ReferenceNumbers']['Reference1'] = 'OrderId:'.$orderID.$coupons_list; | |
} | |
return $order_details; | |
} | |
add_filter( 'hf_ups_order_export', 'alter_ups_order_xml_export_data', 10, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment