Using Metafield Delivery Dates & Time Windows

EasyRoutes natively supports delivery dates and time windows added as attributes on orders.  When these values are stored as attributes in a supported format, they'll automatically be processed for use when planning and scheduling routes.  Delivery dates and time windows stored as metafields on orders can also be transferred to attributes via a Shopify Flow automation by following the guide below.

Additional information on working with metafields can be found in this Shopify Help Center article.

What are metafields and how do I create them?

Metafields allow merchants to collect or store additional information for customers, products, orders, and other aspects of their Shopify account that would not otherwise be included as default values or options - for example, the delivery date and time window preferences for a particular order.

Some third-party apps make use of metafields to store custom information on orders or customers, but Shopify users can configure custom metafield behaviour from the Shopify Settings > Metafields and metaobjects tab shown below:

For example, we'll access the Orders type from the menu above, and click the Add definition button; in the form that appears, we'll configure:

  • Definition pinned (this should be enabled by default)
  • Name: Delivery Date
  • Type: Date
  • Matching draft order definition: Click the + Create draft order definition link here so that this metafield can be configured on draft orders, and will be copied when the draft moves into a "complete" order status (optional if draft orders are not utilized):

Following the same process as above, we'll configure a second metafield as follows:

  • Definition pinned (this should be enabled by default)
  • Name: Delivery Time
  • Type: Single line text
  • Matching draft order definition: Click the + Create draft order definition link again here (optional if draft orders are not utilized).

Once both definitions are saved, a new Metafields panel will display when viewing any order (or draft order, if enabled) in Shopify where a date calendar picker and time text input box can be configured:

Transferring metafields with Shopify Flow

Shopify Flow allows you to create workflows that will run whenever a trigger events occurs - for example, you can structure a Flow as follows to update an order as soon as it is created:

Notes:

  • The examples below assume that metafield definitions are created to align with the Delivery Date and Delivery Time structure described above.
  • Any other metafields can be transferred to order attributes using the same logic described below, though some custom modifications will be required to suit alternate metafield use cases (particularly custom variable addition for Flow access, and code customization to check for and parse any additional metafields).
  • In order for EasyRoutes to automatically pull delivery date/time window from attributes once transferred, either variable must be in an EasyRoutes-supported format, which can be referenced from the appendix below.

To start, navigate to Shopify Flow, and click the Create template button: on the next page, click the Select a trigger button, before searching for "order created" in the trigger list and selecting the Order created • Shopify option.  

This will create a trigger step on your canvas - hover over this step and click the plus icon that appears below it, then select the Action option:

Search for "API" in the action list and select the Send Admin API request • Shopify option - you'll be prompted to search for the type of mutation you'd like to perform.  Search for "orderUpdate" and select the matching mutation as shown below:

A default set of variables will populate the Mutation inputs panel.  Before continuing, we'll need to give Flow access to our two metafield values by clicking the Add variable button just above this default input:

In the modal that appears, search for "metafield" and select the order/ metafield option at the top of the list:

From the dropdown, select either of the two metafield options pertaining to delivery date or time, before clicking the Add button:

Repeat this process again to select the second of the two metafield options - once both have been added, Flow will now have access to each of these variables.  

This can be confirmed by searching "metafield" again from the Add variable menu - both options should now display with live data (green background) for both metafields on the order Flow is using for testing; they will also now be listed as order/deliveryTime and order/deliveryDate as shown below:

Lastly, copy and paste the following code into the Mutation inputs panel, overwriting any existing default inputs:

{
  "input": {
    "id": "{{order.id}}",
    "customAttributes": [
      {% for customAttribute in order.customAttributes %}
      {% unless customAttribute.key == "Delivery Date" or customAttribute.key == "Delivery Time" %}
      {
        "key": "{{customAttribute.key}}",
        "value": "{{customAttribute.value}}"
      },
      {% endunless %}
      {% endfor %}
      {
        "key": "Delivery Date",
        "value": "{{order.deliveryDate.value}}"
      },
      {
        "key": "Delivery Time",
        "value": "{{order.deliveryTime.value}}"
      }
    ]
  }
}

This code does two things:

  • Checks for any other existing attributes on the order, retaining them when the order is updated instead of overwriting them;
  • Copies the date/time metafield values, creating them as Delivery Date and Delivery Time attributes.  If either of these two attributes (with the same name) already exist on the order, they will be overwritten/updated with the new metafield value.

The complete Flow should look like this:

From the upper right-hand corner of the page, click into the More actions menu and select Rename to give this Flow a title; click the Turn on workflow button in the same corner before clicking the Turn on confirmation button.

To test the Flow, from the Shopify Orders page, access any order that has both of the metafield values configured.  Access the More actions menu in the upper right-hand corner, and select Run Flow automation before selecting your newly created Flow to run:

Once the Flow completes running (an Orders page refresh may be required), metafield values should now be displaying within the Additional details panel for the order as attributes:

The same order will now also display within EasyRoutes' Orders page with properly configured delivery date and time window values for route planning:

Appendix

Supported Time Window Formatting:

EasyRoutes automatically detects time windows on Shopify orders with the following order attribute names/keys:

  • Delivery Time
  • Delivery-Time
  • Order Due Time
  • Selected Time
  • Supertime Timeslot

The following time formats are supported for the attribute value:

Format Examples
12-hour time with minutes

"8:15 AM - 2:45 PM"

"8:15 am - 2:45 pm"

"8:15 AM -"

"8:15 am -"

"- 2:45 PM"

"- 2:45 pm"

12-hour time without minutes

"8 AM - 2 PM"

"8 am - 2 pm"

"8 AM -"

"8 am -"

"- 2 PM"

"- 2 pm"

24-hour time

"8:15 - 14:45"

"8:15 -"

"- 14:45"


Supported Delivery Date Formatting:

EasyRoutes automatically detects delivery dates on Shopify orders with the following order attribute names/keys:

  • Delivery Date
  • Delivery-Date
  • Order Due Date
  • Selected Date
  • Supertime Delivery Date

We recommend using the following universal date format for the attribute value, though we will attempt to use other supported date formats:

Format Examples
YYYY-MM-DD

"2025-02-03"

"2026-11-30"

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.