While you'll run into generic Liquid hashes and arrays everywhere, these are the specialized objects (backed by Drop classes, if you're familiar) that Mechanic supports.

  • Shop
  • Collection Scope
  • Collection
  • Order Scope
  • Order
  • Product Scope
  • Product
  • Variant
  • Inventory Item
  • Inventory Level

Shop

This variable is a global – it's always available, no matter what event you're working with.

Object properties

Examples

  • Get the shop's name:
    {{ shop.name }} 
  • Count the products in a collection:
    {{ shop.collections[12345].size }} 
  • Count the products in a shop:
    {{ shop.products.size }} 
  • Get all product IDs in the shop:
    {{ shop.products | map: "id" | join: ", " }} 

Collection Scope

Represents a query that will result in a set of collections, both smart and custom.

Note: this object does not support enumerating all collections.

Object properties

  • []  – accepts a smart or custom collection ID, returns a Collection

Examples

  • Get a collection name:
    {{ shop.collections[12345].name }} 

Collection

Used for both smart collections and custom collections. Available via the Shop object, or as the collection  variable in a task script when run with a shopify/collections/*  event.

Object properties

  • All properties from the Shopify API, for either Custom Collection or Smart Collection
  • collection.products – returns a Products object, scoped to the current collection

Examples

  • Count the products in a specific collection:
    {{ shop.collections[123].products.size }} 

Order Scope

Represents a query for a set of Order objects. Order Scope can be re-scoped in a few different ways.

This object supports enumeration. Loop away! :)

Object properties

  • []  – accepts an order ID, returns a Order
  • count , size  – returns the number of orders that this Order Scope specifies
  • any  – returns an Order Scope object that's refined to include all orders, even closed/cancelled ones
  • open, closed, cancelled, authorized, pending, paid, partially_paid, refunded, voided, partially_refunded, unpaid, shipped, partial, unshipped  – returns a refined Order Scope the way you'd expect :)

Order

Object properties

Product Scope

Represents a query for a set of Product objects. Product Scope can be re-scoped in a few different ways.

This object supports enumeration. Loop away! :)

Object properties

  • []   – accepts a product ID, returns a Product
  • count , size  – returns the number of products that this Products object specifies
  • published  – returns a Products object that's refined to only include published products
  • unpublished   – returns a Products object that's refined to only include unpublished products

Examples

  • Get a product name:
    {{ shop.products[12345].name }} 
  • Count the published products in a shop:
    {{ shop.products.published.size }} 
  • Count the published products in a specific collection:
    {{ shop.collections[123].products.published.size }} 
  • Get all product IDs in a shop:
    {{ shop.products | map: "id" | join: ", " }} 

Product

Available any number of ways, including as the product  variable in a task script when run with a shopify/products/*  event.

Object properties

Examples

  • Get every SKU in your shop:
    {{ shop.products | map: "sku" }} 
  • Fetch all price points for a given product:
    {{ shop.products[12345].variants | map: "price" }} 

Did this answer your question?