How to use Liquid Filters in Shopify to Parse Global ID's

A handy thing to know when working with Shopify's Liquid language

Rob Johnson

By Rob Johnson

Wed Mar 30 2022

Shopify uses an open source language called, Liquid for it's page and email templating and also logic within Shopify Flow. Liquid enables you to add objects/variables dynamically. It's helpful to learn about the syntax and Shopify has good documentation on what it supports:

Liquid Filter Example

You want to place a HOLD on a fulfillmentOrder when an order contains more than 20 items. This will prevent the order from being automatically fulfilled via Shipstation, or whatever 3PL provider you've connected to your store.

You've created a workflow in Shopify Flow that will send an HTTP request once this condition is met. The problem is that the fulfillmentOrders_item.id variable returns as:

gid://shopify/FulfillmentOrder/1234567890

However, the endpoint you're trying to hit requires only the integer of the gid.

/admin/api/2021-10/fulfillment_orders/1234567890/hold.json

So you need to somehow return only the number

1234567890

This is where Liquid Filters come in handy. You can use split and last in the following way to return 1234567890.

{{fulfillmentOrders_item.id  | split: "/" | last}}

The above filter splits on / and grabs the last split item which is 1234567890.

There are a lot of applications for this in Shopify as each major object has a unique global identifyer assigned.