Get and output order metadata

Please note: the following page is for advanced users only. We only give limited support for this advanced option to output serialized order metadata.

Introduction

On this page we explain how to get serialized order metadata and output it on a DYMO label. Not sure what serialized order metadata is? You probably are not using it and can skip this information.

What is serialized data?

A serialized string most likely contains a multi-dimensional array with specific order information. It contains multiple values belonging together and is most-likely added by a plugin.

At this moment WooCommerce itself does not save order metadata as a serialized array.

How to output it on a label

This is for advanced users only. Back-up your website first!

1. Enable advanced options for order metadata

If you want to use advanced options for order metadata you have to enable this function before you can start using it.

You can do this by adding a small filter to a custom plugin or your theme’s functions.php.

Just copy-paste the above code. You do not need to modify it.

2. Choose order metadata for label object

Once advanced options are enabled you’ll get an extra option if you select order metadata. If you select order metadata it will show a link “Toggle advanced options”. If you click on it a new section opens where you can add advanced options for that specific order metadata field.

3. Get serialized array data

To build a query string you need to get example data from an existing order. In the example above we are going to build a query string from order 3657. Click on the link Build query string  to start.

If there is no serialized data available for the specific order metadata it will show an error.

If there is a serialized data available it will output the complete (multi-dimensional) array. The example below shows serialized data for the (Dutch) MyParcel plugin which is used for shipping.

4. Build a query string

To build a query string you click on the underlined items.
This will add array keys to the textbox behind “Query string for serialized data“.

The example query string from the screenshot below is build in three steps (marked in red on the screenshot):

  1. Parent array contains a unique ID, we leave it empty: [] (just two square brackets)
  2. Child array contains a array with key “shipment”: [shipment]
  3. Array value with key “barcode”: [barcode]

The query string will output as:

[][shipment][barcode]

The label will contain the shipment-barcode.