Skip to content

Instantly share code, notes, and snippets.

@hedqvist
Created January 22, 2020 14:43
Show Gist options
  • Select an option

  • Save hedqvist/b6372ae86e4e25a0b5a86bdb83197ad2 to your computer and use it in GitHub Desktop.

Select an option

Save hedqvist/b6372ae86e4e25a0b5a86bdb83197ad2 to your computer and use it in GitHub Desktop.
Support for WooCommerce Shipment Tracking
<?php
/**
* @snippet WooCommerce - Unifaun plugin by Redlight Media - Add Support for WooCommerce Shipment Tracking
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.9.0
*/
add_action( 'ac_wc_unifaun_shipment_print_successful_print', 'redlight_postnord_add_tracking', 10, 3 );
function redlight_postnord_add_tracking($body, $response, $order){
$provider = 'PostNord Sverige AB';
if ( isset( $body->pdfs ) ) {
foreach ( $body->parcels as $parcel ) {
if ( function_exists( 'wc_st_add_tracking_number' ) ) {
wc_st_add_tracking_number( $order->get_id(), $parcel->parcelNo, $provider);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment