Skip to content

Instantly share code, notes, and snippets.

@PluginHive
Created April 23, 2020 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PluginHive/1437b2fac7d9ca56ed0f9cc89239df59 to your computer and use it in GitHub Desktop.
Save PluginHive/1437b2fac7d9ca56ed0f9cc89239df59 to your computer and use it in GitHub Desktop.
Code snippet for UPS shipment tracking numbers to be included in the order export CSV/XML. Supported PluginHive plugin: https://www.pluginhive.com/product/woocommerce-ups-shipping-plugin-with-print-label/
// BEGIN export PluginHive WooCommerce UPS Shipping plugin tracking code. */
add_filter('hf_alter_csv_header', 'hf_csv_order_add_more_columns', 10, 1);
function hf_csv_order_add_more_columns($csv_columns) {
$csv_columns['ups_created_shipments_details_array'] = 'UPS Tracking Number';
return $csv_columns;
}
add_filter('hf_alter_csv_order_data', 'hf_csv_order_add_more_data', 10, 1);
function hf_csv_order_add_more_data($order_data) {
$additional_meta['ups_created_shipments_details_array'] = 'ups_created_shipments_details_array';
foreach ($additional_meta as $key => $val) {
$post_meta = get_post_meta($order_data['order_id'], $val, TRUE);
if (is_array($post_meta)) {
$order_data[$key] = key($post_meta);
}else{
$order_data[$key] = $post_meta;
}
}
return $order_data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment