How to Add Shipment Tracking to Woocommerce?

Currently, Woocommerce does not have a shipment tracking option and therefore your customers are unable to see the correct data about the orders. Now, in this tutorial I‘m going to show you how to add shipment tracking to Woocommerce. It will work as a charm and will show the tracking code on the orders table, single orders page and will send tracking information related emails to your customers.

Also, as a bonus – it will add the Track button to your orders page in a way that by clicking on the button the correct tracking provider site is opened. So, stay tuned.

Option 1: How to Add Shipment Tracking to Woocommerce with the plugin?

I’m going to show you two different options and first of them is adding a tracking system to Woocommerce with the help of a plugin. The best free plugin I can recommend is Advanced Shipment Tracking for WooCommerce plugin.

This awesome plugin lets you add tracking information to orders and provides your customers an easy way to track their orders. Also, you can manage and automate your post-shipping orders flow, reduce time spent on customer service.

Step 1: Install the Advanced Shipment Tracking for WooCommerce plugin

Go to Plugins >> Add new and search form Advanced Shipment Tracking for WooCommerce. Install and activate it.

Next, go to Woocommerce >> Shipment tracking and select the options you want to use.

Step 2: Choose the providers

Currently, there are 397 shipping provider you can choose from. All of them are activared by default but you can deactivate them if you want.

If there is something missing then press on the Custom button and you’ll be able to add your own providers.

Step 3: Customize emails

Under Shipment tracking >> Settings you’ll find Launch Customizer button. If you click on it youl’ll be able to customize the content and appearance of the transactional emails.

Step 4: Activate Actions

Go to Woocommerce >> Orders and under the Screen Options activate Actions. If you do that you will be able to use quick icons to modify your orders (see the screnshot).

How to Add Shipment Tracking System to Woocommerce?

Step 5: Add tracking information to orders

Since all the cusotmizations are done you can go and open up an order and add the tracking information. Just add the tracking code, choose the provider and select whether the order is shipped or partially shipped. Save and you’re done.

If everything is done then the end result should look like this.

How to Add Shipment Tracking System to Woocommerce?

Option 2: How to Add Shipment Tracking System to Woocommerce with the code?

Advanced Shipment Tracking plugin has a lot of options but maybe you don’t need something so sophisticated and you just need to add a tracking code (or information) to the orders. Well, take a look at the code snippet here below.

Step 1: Install a Code Snippets plugin

Code Snippets plugin is a free plugin which allows your to run PHP/HTML/CSS/JavaScript code snippets on your site without the need to modify functions.php. The plugin can be found here. In this tutorial we are going to use this plugin to add one code snippet

Another option, paste the code snippets shown below to your child theme’s functions.php file.

Step 2: Copy the code to the code box

Go to Snippets >> Add new

Now give it a meaningful title and paste this code here below to the code box.

This code will add a tracking info meta box to your orders. All the information saved there will be shown on the orders table and single orders page. If you want to change the column title look for “Tracking code” string inside the code.

// For displaying in Order page columns.

add_filter( 'manage_edit-shop_order_columns', 'set_tracking_column' );
function set_tracking_column($columns) {
    $columns['tracking_column'] = __( 'Tracking code', 'your_text_domain' );
    return $columns;
}

// Add the data to the custom columns for the order post type:
add_action( 'manage_shop_order_posts_custom_column' , 'custom_shop_order_column', 10, 2 );
function custom_shop_order_column( $column, $post_id ) {
    switch ( $column ) {
        case 'tracking_column' :
            echo esc_html( get_post_meta( $post_id, 'tracking_column', true ) );
            break;
    }
}

// For display and saving in order details page.
add_action( 'add_meta_boxes', 'tracking_code_meta_box' );
function tracking_code_meta_box() {
    add_meta_box(
        'tracking_column',
        __( 'Tracking code', 'your_text_domain' ),
		'shop_order_display_callback',
		'shop_order'
    );
}

// For displaying it correctly
function shop_order_display_callback( $post ) {
    $value = get_post_meta( $post->ID, 'tracking_column', true );
    echo '<textarea style="width:100%" id="tracking_column" name="tracking_column">' . esc_attr( $value ) . '</textarea>';
}

// Saving the input data
function save_tracking_code_meta_box_data( $post_id ) {
	
    // If this is an autosave, our form has not been submitted, so we don't want to do anything.
    if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
        return;
    }

    // Check the user's permissions.
    if ( isset( $_POST['post_type'] ) && 'shop_order' == $_POST['post_type'] ) {
        if ( ! current_user_can( 'edit_shop_order', $post_id ) ) {
            return;
        }
    }

    // Make sure that it is set.
    if ( ! isset( $_POST['tracking_column'] ) ) {
        return;
    }

    // Sanitize user input.
    $my_data = sanitize_text_field( $_POST['tracking_column'] );

    // Update the meta field in the database.
    update_post_meta( $post_id, 'tracking_column', $my_data );
}

add_action( 'save_post', 'save_tracking_code_meta_box_data' );


// Showing the info on My orders page

// New column on My orders page

add_filter( 'woocommerce_account_orders_columns', 'add_account_orders_column', 1, 1 );
function add_account_orders_column( $columns ){
    $columns['tracking-column'] = __( 'Tracking code', 'woocommerce' );

    return $columns;
}

add_action( 'woocommerce_my_account_my_orders_column_tracking-column', 'add_account_orders_column_rows' );
function add_account_orders_column_rows( $order ) {
    // Example with a custom field
    if ( $value = $order->get_meta( 'tracking_column' ) ) {
        echo esc_html( $value );
    }
}

// Showing tracking code on View order page and on Thank you page

add_action( 'woocommerce_thankyou', 'tracking_on_thankyou_page', 20 );
add_action( 'woocommerce_view_order', 'tracking_on_thankyou_page', 20 );
 
function tracking_on_thankyou_page( $order_id ){  ?>
    <table class="woocommerce-table shop_table gift_info">
        <tbody>        
            <tr>
                <th>Tracking code</th>
                <td><?php echo wpautop( get_post_meta( $order_id, 'tracking_column', true ) ); ?></td>
            </tr>
        </tbody>
    </table>
<?php }

If everything goes well then the end result should look like this.

How to Add Shipment Tracking System to Woocommerce?

So, here it is. Now you know how to add shipment tracking to Woocommerce. Go and add on to your system right now.

Video: How to Add Shipment Tracking to Woocommerce

Useful Tips

Here are some of my favorite Wordpress tools

Thank you for reading this article. I hope you found it helpful as you build your own websites and e-commerce sites. Here are some tools I use as a Wordpress developer and enthusiast that I hope you’ll also find helpful.

These are affiliate links, so if you do decide to use any of them, I’ll earn a commission and this helps me create these tutorials and make Youtube videos. But in all honesty, these are the exact tools that I use and recommend to everyone, even my friends and family.

Themes: For the last couple of years I have two go-to themes which I use for every kind of projects. Those two themes are Blocksy theme and Kadence Theme. On this site and my Youtube channel you’ll see a lot of tutorials I have made about them. If you would like to get a 10% discount for both of them then:

Contact forms: There are hundreds of contact forms out there but Fluent Forms is the one I like the most. If you need a 20% discount then use this link (save 20% coupon is WPSH20).

Gutenberg add-ons: If I need a good Gutenberg blocks add-on then Kadence Blocks is the one I have used the most. You’ll get 10% discount with the coupon SIMPLEHACKS here.

Website migration: While building a website you probably need a good plugin that can help you with the migration, backups, restoration and staging sites. Well, WpVivid is the one I have used for the last couple of years. If you use this link along with the WPSH20 coupon you’ll get 20% discount.

Woocommerce extensions: There are a bunch of Woocommerce extensions that I really like but the one that stands really out is Advanced Dynamic Pricing. Once again, you’ll get a 20% discount if you use this link here (save 20% coupon is WPSH20)

Web Hosting: For getting started, I really like A2 Hosting. They have the dedicated and fast Wordpress hostinh and support has also been fast and responsive. If you’re more tech savvy and want to have a really fast managed cloud hosting then I recommend Cloudways. (Btw, this site is hosted in Cloudways.)

To see all my of most up-to-date recommendations, check out this resource that I made for you!

Do you want to thank me and buy me a beer?

Every donation is entirely welcome but NEVER required. Enjoy my work for free but if you would like to thank me and buy me a beer or two then you can use this form here below.

Choose amount

Best selling plugins

Default image
Janek T.
I am a Wordpress enthusiast who has been making websites since 2011. In this site I am offering simple to follow tips on how to use Wordpress and Woocommerce. If you want to be the first to be notified about the new tutorials then please subscribe to my Youtube channel here Follow me in Twitter here
Articles: 72