Skip to content

Display rules for functions

Functions use the same rule builder as blocks: groups joined with AND, rules inside a group joined with OR. See how display rules work.

What’s different is which rules you can use. A Shopify Function can only read the checkout data it asks Shopify for up front, and each function type asks for different data. So each function type, and each rule set, offers its own list of rules.

Some functions show Rule Set 1, Rule Set 2 and so on when you choose Apply only when rules pass. Each rule set is a separate list of rules. Pick the one that has the rules you need.

  • You choose the rule set when you create the function. It can’t be changed afterwards.
  • Switching rule set while creating a function clears the rules you’ve added.
  • To use rules from two rule sets, create two functions.

One cart attribute key per function. A function reads the key from the first Cart attribute key, value rule and no other. A second rule with a different key never matches. Use one key per function, or create a separate function. The exception is Rule Set 4 of the checkout blocker, which reads up to 5 keys.

One metafield per kind. The same applies to Line attribute key, Customer metafield, Company metafield, and Company location metafield: only the namespace and key in the first rule of each kind are read.

Tags are read when you save. Customer tags, product tags, attribute keys, and metafield names are sent to Shopify when you save the function. If you edit these, click Save function again for the change to take effect.

Amounts are in your store’s currency. Money rules convert your amount to the customer’s currency before comparing. Avoid is equal to for money, because converted amounts rarely match exactly.

Customer rules and guests. Customer tags and Customer account exists only work for logged-in customers. A guest has no tags, so Customer tags includes fails and does not include passes.

Hide, rename, and reorder payment methods.

Rule set Rules
1 Cart products, Cart total, Cart subtotal, A line item subscription exists / does not exist, Cart attribute key, value, Line item product title, Customer account exists, Customer tags, B2B customer exists / does not exist, Delivery country, Delivery province, Delivery zip/postal code, Delivery city, Selected shipping option title, Delivery method type, Delivery address company exists / does not exist
2 Company location metafield (is equal to, is not equal to, is more than, is less than), Line item product tags

Hide accelerated checkout payment methods: Cart attribute key, value, and Customer tags.

B2B order review: Cart subtotal, Cart attribute key, value, Company location metafield, Company location metafield compared to order subtotal, Quantity of variants, Customer tags, Line item product tags.

Hide, rename, and reorder shipping methods.

Rule set Rules
1 Cart products, Cart total, Cart subtotal, Cart attribute key, value, Line item price ends in, Customer account exists, Customer tags, B2B customer exists / does not exist, Delivery country, Delivery province, Delivery zip/postal code, Delivery zip/postal codes, Delivery city, Delivery address (line 1) regex, Delivery cost, Line item variant title, Line item product title, All line item variant titles, All line item product titles
2 Line item product tags, Quantity of items with product tags, Line item product type, All line item product types, Cart total, Cart subtotal, Number of line items, Number of items, A line item subscription exists / does not exist, Customer tags, Delivery country, Delivery province, Delivery zip/postal code, Delivery city
3 Company location metafield, Company metafield, Delivery province, Delivery zip/postal code, Delivery zip/postal codes, Delivery city, Delivery cost, Total cart weight (kg)
Function Rule set Rules
Product discount, Product discount code 1 Cart total, Cart subtotal, Cart total (excluding selected variants), Cart subtotal (excluding selected variants), Cart products, Quantity of variants, User is a customer, Customer tags, User is authenticated as a customer, Line attribute key, Line attribute key, value, Total cart weight (kg)
2 Customer metafield, Company metafield, Is POS checkout, Is not POS checkout, POS location ID
Collection discount, Collection discount code 1 Cart total, Cart subtotal, Cart products, Cart attribute key, value, Cart collections, Cart collections quantity, Individual product quantity in collection, Cart collections total value, Customer tags, User is a customer, User is authenticated as a customer, User is not authenticated as a customer, Line attribute key, Line attribute key, value
2 Customer metafield, Company metafield, Buyer identity email
Order discount, Order discount code 1 Cart total, Cart subtotal, Cart products, Quantity of variants, Cart attribute key, value, Line attribute key, Line attribute key, value, Line attribute key, value quantity, Quantity of items added by Checkout Buddy, User is a customer, User is authenticated as a customer, Customer tags, B2B customer exists / does not exist, Company metafield, Cart collections, Cart collections quantity, Cart collections quantity (unique variants), Quantity from each collection, Is POS checkout, Is not POS checkout, POS location ID
2 Customer metafield, Company metafield
Shipping discount 1 Cart total, Cart subtotal, Number of items, Cart products, Quantity of variants, Line item product tags, All line items product tags, A line item subscription exists / does not exist, Line attribute key, Line attribute key, value, Total cart weight (kg), Customer tags, User is a customer, User is authenticated as a customer, Cart attribute key, value, Delivery country
2 Customer metafield, Company metafield, B2B customer exists / does not exist, Number of items

On Order discount Rule Set 1, Company metafield always reads the company metafield checkout_buddy.trigger. Create a company metafield definition with that namespace and key, fill it in on each company, and compare against it. Every other Company metafield rule lets you type any namespace and key.

Line attribute rules on product and collection discounts are checked per line: only lines that have the attribute get the discount.

Function Rule set Rules
Checkout blocker 1 Cart products, Number of items, Number of line items, Quantity of items with a subscription, Subtotal value of line items with a subscription, Line item product type, Quantity of variants, Quantity of free variants, Quantity of freebies, Free item quantity exceeds selected product quantity, Quantity of each variant, Quantity of product types, Quantity of items with a subscription (by name), Customer tags, User is authenticated as a customer, User is not authenticated as a customer, B2B customer exists / does not exist, Cart subtotal, Cart total, Cart attribute key, value, Cart contains both subscriptions and one time purchases
2 Cart total, Cart subtotal, Customer metafield, Company metafield, Quantity of items with a subscription (by name), Quantity of line items with a subscription (by name), Line item product type, Line attribute key, Line attribute key, value, Cart contains both subscriptions and one time purchases, Quantity of variants
3 Cart subtotal, Delivery zip/postal code, Delivery zip/postal codes, Shipping city, Shipping country, Shipping province, Selected shipping option title
4 Cart attribute key, value (up to 5 different keys)
Address blocker – Total cart weight (kg), Shipping address 1, Shipping address 2, Shipping country, Shipping province, Delivery zip/postal code, Delivery zip/postal codes, Shipping city
Function Rule set Rules
Line item price changer 1 Cart total, Cart products
2 Cart total, Cart products, Cart attribute key, value, Customer tags, Customer metafield
Multi line item price changer – Cart total, Cart products, Cart attribute key, value, Customer metafield, Customer tags, B2B customer exists / does not exist, Quantity of variants

These rules aren’t available to blocks, because checkout blocks can’t see the data:

  • Customer tags
  • User is a customer, User is authenticated as a customer
  • Customer metafield (any namespace and key)
  • Company location metafield, Company location metafield compared to order subtotal
  • Buyer identity email
  • Is POS checkout, Is not POS checkout, POS location ID
  • Delivery address (line 1) regex, Delivery cost, Delivery method type
  • Line item price ends in
  • Subscription quantity rules and Cart contains both subscriptions and one time purchases

Matching is mostly the same as for block rules. The differences:

  • Customer tags: comma list; passes if the customer has any of the tags.
  • Delivery zip/postal code works differently by function:
    • Payment and shipping methods: a comma list. A code matches if it appears anywhere in the customer’s zip, and M5V* matches codes starting with M5V. Don’t leave a trailing comma, or the rule matches every zip.
    • Checkout blocker: one code, matched against the start of the zip.
    • Address blocker: one code that must match the whole zip, or end it with * to match the start.
  • Delivery city: comma list; the whole city name must match, ignoring capitals.
  • Delivery country, Delivery province: one country or province code per rule.
  • POS location ID: comma list; matches when the location’s ID contains the number you type.
  • Cart attribute key, value with is more than / is less than: most functions compare the values as text, so 10 counts as less than 9. Stick to is equal to and is not equal to unless the values are the same length.
  • Delivery address (line 1) regex: a regular expression, case-sensitive unless you start it with (?i).

When a function needs something only a block can see

Section titled “When a function needs something only a block can see”

Functions can’t see the selected payment method, the order note, or the date or time. If you need one of those, let a block see it and pass it to the function as a cart attribute. See use block conditions in a function.

Form field answers are already saved as cart attributes, so a function that offers Cart attribute key, value can check them directly.