Skip to main content

Order Tags

Applying order tags using custom liquid variables

Written by Steve Jones

Alpaca can add tags to your Shopify orders automatically. You set these up in Settings → Orders & checkout → Order tags.

Each tag you add can be plain text, such as alpaca, which is added to every order. It can also use Liquid, so the tag depends on the order. For example, you can tag only orders that have been packed, or tag each order with its pickup location.

There are also two built-in options on the same page:

  • Tag orders with pickup time (if applicable)

  • Tag orders with delivery time (if applicable)

When does Alpaca apply order tags?

Alpaca works out your order tags and updates them on the order whenever one of these happens:

  • A new order is placed.

  • You mark an order as packed or partially packed in Alpaca.

  • You unpack an order in Alpaca, moving it back to new.

  • You mark an order as fulfilled in Alpaca. This includes bulk updates and completing a stop on a delivery route.

  • You cancel an order in Alpaca.

  • The customer reschedules their pickup or delivery time from their order status page.

  • You change the delivery method for an order.

  • You remove the scheduled time from an order.

  • An order is marked as abandoned automatically.

Each time, Alpaca re-checks every tag rule. It adds tags that now apply and removes ones that no longer do. For example, a "packed" tag is removed if the order is unpacked.

Changes made outside of Alpaca

Tags aren't updated when an order changes in Shopify rather than in Alpaca. Examples are fulfilling or cancelling an order directly in Shopify, or cancelling a fulfilment there. The tags will catch up the next time one of the actions above happens to that order.

Examples

Add each of these as its own tag. If a tag works out to be blank for an order, nothing is added.

Tag orders once they're packed

{% if order.status == 'PACKED' %}alpaca-packed{% endif %}

Tag orders by fulfilment method

{% if order.type contains 'pickup' %}pickup{% elsif order.type contains 'delivery' %}delivery{% else %}shipping{% endif %}


​Tag orders with their pickup or fulfilment location

{{ location.name }}

To get a lower-case tag with hyphens instead of spaces, e.g. leeds-store:

{{ location.name | downcase | replace: ' ', '-' }}

Tag orders with their delivery rate

{% if order.delivery_rate_name %}Rate: {{ order.delivery_rate_name }}{% endif %}

Tag delivery orders that are packed and ready to go out

{% if order.type contains 'delivery' and order.status == 'PACKED' %}ready-for-driver{% endif %}

Tag orders with items that aren't available

{% unless order.itemsAreAvailable %}stock-issue{% endunless %}

Tag orders where any item has a particular line item property

{% for item in order.line_items %}{% if item.properties_map['Gift wrap'] %}gift-wrap{% break %}{% endif %}{% endfor %}

Tag orders that contain a particular SKU

{% for item in order.line_items %}{% if item.sku == 'GIFT-BOX' %}contains-gift-box{% break %}{% endif %}{% endfor %}

The {% break %} in these two examples stops the tag being repeated when more than one item matches.

Tag orders paid with a particular payment method

{% if order.payment_gateway_names contains 'Cash on Delivery (COD)' %}cash-on-delivery{% endif %}

Tag high-value orders

{% assign total = order.total | plus: 0 %}{% if total >= 100 %}high-value{% endif %}

Tag orders by the customer's language

{% if customer.locale == 'fr' %}french-speaking{% endif %}

Things to watch

  • No commas. A tag can't contain a comma, either in the Liquid itself or in the value it produces. That rules out values such as addresses and order.product_tags.

  • Avoid values that change. Timestamps, order.hours_remaining and location.now produce a different tag every time tags are refreshed.

  • Keep personal details out of tags. Don't put customer names, emails or phone numbers in tags.

  • Capitals matter. Compare statuses in capitals, e.g. order.status == 'PACKED', not 'packed'.

  • Filters. Standard Liquid filters such as downcase, upcase, replace and plus all work. Alpaca also provides money and money_with_currency.

Liquid variable reference

Order tags can use four objects: order, location, customer and shop.

order

Variable

What it contains

order.name

Shopify order name, e.g. #1234

order.id

Alpaca's order ID

order.shopify_id

Shopify's numeric order ID

order.type

How the order is being fulfilled: alpaca:pickup, alpaca:delivery, alpaca:shipping, shopify:pickup, shopify:delivery or shopify:shipping

order.status

NEW, PACKED, PARTIALLY_PACKED, FULFILLED, NOT_FULFILLED or CANCELLED

order.itemsAreAvailable

true or false

order.total

Order total

order.subtotal

Order subtotal

order.note

Order note

order.payment_gateway_names

List of payment methods used

order.pickup_time

Pickup date and time, in the customer's language

order.pickup_time_start / order.pickup_time_end

Start and end of the pickup slot (slot-based pickups only)

order.delivery_time

Delivery date and time, in the customer's language

order.delivery_time_start / order.delivery_time_end

Start and end of the delivery slot (slot-based deliveries only)

order.pickup_timestamp / order.delivery_timestamp / order.scheduled_timestamp

Scheduled time as a timestamp in milliseconds

order.processed_at / order.processed_at_utc

When the order was placed, as a timestamp in milliseconds (store time or UTC)

order.hours_remaining

Hours until the scheduled time

order.delivery_rate_id

ID of the delivery rate used

order.delivery_rate_name

Name of the delivery rate, if there is one

order.shipping_rate_name

Name of the shipping rate, if there is one

order.product_tags

Tags from the product rules that matched the order, separated by commas

order.line_items

List of line items (see below)

order.address_long / order.address_full

Shipping address

order.tracking_url

Tracking URL

order.token

Order token

order.order_status_url

The customer's order status page

order.schedule_url / order.pickup_schedule_url / order.delivery_schedule_url

Links the customer can use to reschedule

Line items

Each item in order.line_items has Shopify's line item fields, such as title, sku, quantity, vendor, product_id, variant_id and properties.

It also has properties_map, which lets you look up a line item property by name, e.g. item.properties_map['Gift wrap'].

location

The pickup or fulfilment location for the order.

Variable

What it contains

location.name

Location name

location.id

Location ID

location.address, location.address1, location.address2

Address lines

location.city, location.province, location.provinceCode

City and province or state

location.country, location.countryCode, location.postalCode

Country and postcode

location.address_long, location.address_full

Full address

location.phone

Phone number

location.pickup_instructions

Pickup instructions

location.timezone

Time zone, e.g. Europe/London

location.store_hours

List of opening hours, each with days and hours

location.now, location.now_formatted

The current time

customer

Variable

What it contains

customer.name

Full name

customer.first_name, customer.last_name

First and last name

customer.email

Email address

customer.phone

Phone number

customer.locale

Customer's language, e.g. en

shop

Variable

What it contains

shop.name

Store name

shop.domain

Store's myshopify.com domain

shop.contact_email

Store contact email

shop.shopify_id

Shopify's numeric store ID

Did this answer your question?