How to Add Shipment Tracking to WooCommerce Orders with ACF - Robert Mullineux

How to Add Shipment Tracking to WooCommerce Orders with ACF

Provide Order Tracking With ACF

Facebook
Twitter
Reddit

In this tutorial, we will explore how to enhance the order tracking experience in WooCommerce by integrating shipment tracking using Advanced Custom Fields (ACF). With this implementation, you can easily add a tracking ID to your orders and provide customers with a convenient way to track their shipments. Let’s dive in!

What is Order Tracking

Order tracking allows customers to monitor the progress of their package from the moment it leaves the warehouse until it reaches their doorstep. By adding shipment tracking functionality to your WooCommerce orders, you enhance transparency and customer satisfaction.

Australian Shipping/Courier Companies

When it comes to Australian shipping and courier services, several providers excel in delivering packages across the country. Here are five popular shipping providers in Australia worth considering:

  • Australia Post
  • TNT Australia
  • DHL Express Australia
  • Fastway Couriers
  • CouriersPlease

Setting up the ACF Field

To begin, follow these steps to set up the ACF field for the tracking ID:

  1. Add a new Field Group called “Order Custom Field” in ACF.
  2. Within the Field Group, create a text field named “Tracking ID.”
  3. Configure the field settings to show the field group only if the post type is “order.”

Adding Shipment Tracking Link to Order Complete Email

To include a shipment tracking link in the Order Complete email, use the following custom hook function:


function add_shipment_tracking_link_to_email($order, $sent_to_admin, $plain_text, $email) {
    $tracking_id = get_field('tracking_id', $order->get_id());
   
    if ($tracking_id) {
        $tracking_url = 'https://auspost.com.au/mypost/track/#/details/' . $tracking_id; // Generate the tracking URL for the specific shipping provider using the tracking ID
        $button_style = 'display:block; padding:20px; background:#222; color:#FFF; text-align:center;';
       
        echo '<p><a href="' . $tracking_url . '" style="' . $button_style . '">Track Your Order</a></p>';
    }
}
add_action('woocommerce_email_order_details', 'add_shipment_tracking_link_to_email', 20, 4);

Remember to replace $tracking_url with the actual tracking URL for the selected shipping provider. Additionally, the code above styles the tracking link as a button with a block display, padding, and appropriate colors. In the PHP snippet code above, I have included Australia Post’s tracking link for the purpose of this example. If you choose to use a different shipping provider (such as TNT, FedEx or Aramex to name a few) you will need to replace the tracking URL with the consignment tracking URL from your chosen provider.

Adding Tracking ID to the Field in Edit Order Screen: To add the tracking ID to the field in the Edit Order screen, simply navigate to the order you wish to modify, locate the “Order Custom Field” section, and enter the tracking ID into the “Tracking ID” text field. Save the changes once done.

order-details
Order Details Screen with ACF Field displayed on right

 

order-custom-field-tracking-id
ACF Custom Field with Tracking ID added

 

order-details-email-track-order-button

By integrating shipment tracking with ACF in WooCommerce, you can provide your customers with a seamless tracking experience. This tutorial has guided you through the steps of setting up the ACF field, including a tracking link in the Order Complete email, and adding the tracking ID to the field in the Edit Order screen. Use these steps as a foundation and customise them according to your specific requirements. Enhance your customers’ post-purchase experience with accurate and reliable shipment tracking.

Ready to take your eCommerce business to the next level? Contact me today for professional eCommerce development services that will elevate your online store and drive sales. Let’s collaborate to create a seamless shopping experience for your customers, tailored to your unique needs. Request a quote online and let’s bring your eCommerce vision to life!

Facebook
Twitter
Reddit

Get In Touch