WooCommerce saves any additional order information in the Post Meta table in a key value format.

While the Email Customizer for WooCommerce supports all the built-in default values of the order object, there might be scenarios where you might have used a plugin or created custom fields to save additional information for an order.

A good example is the Shipment Tracking ID. Here is a screenshot showing the custom field

 This custom field usually gets saved in the wp_postmeta table as a meta_key and meta_value

In the above example,

meta_key = tracking_id (it is always good to use an underscore instead of spaces)
meta_value = 123433535


Similarly, most shipment tracking id plugins save the data to the order (post) meta table. You can easily cross-check with the developer of the plugin to know where they save the data. It would most probably in the order meta (post meta) table.

You can easily fetch this data using the Custom Short Code feature in our plugin.

Step 1:

Create a custom short code following this guide

TIP: While creating the custom short code, make sure you use the same key value as your short code as well. Example: if the meta key is saved as "tracking_id", use the same key for the short code as well.

Example: [woo_mb_custom_code type="tracking_id"] 

Step 2:

As outlined in the above guide, make sure you created the custom_code.php in your theme/child theme folder path.

Edit the custom_code.php from the override location

You can use an example like this:

if(isset($attr['type']) && $attr['type'] == 'tracking_id'){
   $tracking_id = get_post_meta( $order->get_id(), 'tracking_id', true );
   echo  $tracking_id;
}

When an email is sent to the customer, this will output the Tracking ID replacing your custom short code.


IMPORTANT NOTE: You should know the META KEY in order to fetch the data.  

  • When you are using a plugin: You can obtain the meta key from the respective plugin developer 
  • When you use the meta fields: You can use the same key that you entered in the custom fields

Need some assistance with this set up ? Just submit a support request

 

 



Did this answer your question?