Developer Features:

Shipment Tracker for Woocommerce provides few options for developers to consume shipment data directly into the custom php code through actions, public functions and shortcode.

Here is the list of developer features currently supported by plugin:

 

Here are the description of each of them:

Shortcode:

1. [bt_shipping_tracking_form_2]

Create your own public facing order tracking page using this shortcode.

Just copy following code where you want to display the order tracking form:

			[bt_shipping_tracking_form_2]

You can customize the look and feel of the form and results table by applying custom css. Just use wordpress customizers or your child theme to add custom css like this:

					<style>
						#_bt_shipping_tracking_from{

						}
						#_bt_shipping_tracking_from input {

						}
						#_bt_shipping_tracking_from input[type="submit"]{

						}
						#_bt_shipping_tracking_response {

						}
						#_bt_shipping_tracking_response thead th {

						}
						#_bt_shipping_tracking_response td {

						}
						#_bt_shipping_tracking_public .table-responsive {

						}
						</style>
					
				

 

Action Hook:

1. add_action( 'bt_shipment_status_changed',...);

Fires whenever shipment status is updated for any order.

Parameters:

$order_id

(number) The ID of the order whose shipment tracking details have been updated.

$shipment_obj

(Bt_Sync_Shipment_Tracking_Shipment_Model) Object containing shipment tracking information of the order.

$shipment_obj_old

(Bt_Sync_Shipment_Tracking_Shipment_Model) Object containing previous shipment tracking information of the order.

Example:

		<?php

		function bt_shipment_status_changed_callback( $order_id,$shipment_obj,$shipment_obj_old) {
			//latest shipment tracking:
			$courier_name = $shipment_obj->courier_name;
			$current_status = $shipment_obj->current_status;
			$awb = $shipment_obj->awb;
			$tracking_url = $shipment_obj->tracking_url;

			//previous shipment tracking:
			$old_courier_name = $shipment_obj_old->courier_name;
			$old_current_status = $shipment_obj_old->current_status;
			$old_awb = $shipment_obj_old->awb;
			$old_tracking_url = $shipment_obj_old->tracking_url;

			// do stuff

		}
		add_action( 'bt_shipment_status_changed', 'bt_shipment_status_changed_callback', 10, 3 );

 

Public Functions:

1. bt_get_shipping_tracking($order_id);

Returns associative array containing shipment tracking data of a specific order.

Parameters:

$order_id

(number) The ID of the order whose shipment tracking details have been updated.

Returns:

Array

(Array) Associative array containing shipment tracking data.

Example:

			<?php

			if(function_exists('bt_get_shipping_tracking')) {
				$shipment_obj = bt_get_shipping_tracking($order_id);
				if($shipment_obj != null){
					$courier_name = $shipment_obj["courier_name"];
					$current_status = $shipment_obj["current_status"];
					$awb = $shipment_obj["awb"];
					$tracking_url = $shipment_obj["tracking_url"];
				}            
			}

 

2. bt_force_sync_order_tracking($order_id);

Fetches shipment tracking information from the respective shipment provider that is associated with the specific order.

Parameters:

$order_id

(number) The ID of the order whose shipment tracking details have been updated.

Returns:

Array

(Array) Associative array containing shipment tracking data.

Example:

			<?php

			if(function_exists('bt_force_sync_order_tracking')) {
				$shipment_obj = bt_force_sync_order_tracking($order_id);
				if($shipment_obj != null){
					$courier_name = $shipment_obj["courier_name"];
					$current_status = $shipment_obj["current_status"];
					$awb = $shipment_obj["awb"];
					$tracking_url = $shipment_obj["tracking_url"];
				}            
			}

 

3. bt_update_shipment_tracking($order_id,$courier_name,$awb_number,$shipping_status,$edd,$tracking_link);

Saves shipment tracking data of an order.

Parameters:

$order_id

(number) The Order ID.

$courier_name

(string) Courier Name.

$awb_number

(string) AWB Number.

$shipping_status

(string) Shipping Status.
Possible Values: pending-pickup, out-for-pickup, in-transit, out-for-delivery, delivered, canceled, rto-in-transit, rto-delivered
Note: Assigning a value other than above will also work.

$edd

(string) Estimated Delivery Date (eg. 2022-03-15).

$tracking_link

(string) The Tracking url. Set to empty string to use global tracking url defined in plugin settings.

Returns:

Array

(Array) Associative array containing shipment tracking data.

Example:

			<?php

			if(function_exists('bt_update_shipment_tracking')) {
				$shipment_obj = bt_update_shipment_tracking($order_id,$courier_name,$awb_number,$shipping_status,$edd,$tracking_link);
			}

 

Filters:

			<?php

				function bt_sst_product_page_delivery_checker_label_text($content) {
					$content .= '

This is a message added by the shortcode filter.

'; return $content; } add_filter('bt_sst_product_page_delivery_checker_label_text', 'bt_sst_product_page_delivery_checker_label_text'); function bt_sync_shimpent_track_pincode_checker_shipping_to_text($content) { $content = 'Select a delivery location to see product availability and delivery options'; return $content; } add_filter('bt_sync_shimpent_track_pincode_checker_shipping_to_text', 'bt_sync_shimpent_track_pincode_checker_shipping_to_text');

 

Feature requests are welcome :-)