Skip to content

Conditions for functions

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

What’s different is which conditions 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 condition set, offers its own list of conditions.

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

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

Discounts need a condition to be conditional. A discount on Apply only when conditions pass, or a code rule on Only when conditions pass, can’t be saved without a condition: add one, or pick Apply to all checkouts (Every checkout on code rules). A discount saved with none before this check applies to every checkout, and asks for a condition the next time you save it.

One cart attribute key per function. A function reads the key from the first Cart attribute key and value condition and no other. A second condition with a different key never matches. Use one key per function, or create a separate function. The exception is Condition 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 condition of each kind are read. The form warns under a condition on another key, for example “One cart attribute key per discount”.

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 again for the change to take effect.

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

Customer conditions and guests. Customer tags and Customer has an account 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.

Condition set Conditions
1 Cart products, Cart total, Cart subtotal, A line item subscription exists / does not exist, Cart attribute key and value, Line item product title, Customer has an account, Customer tags, B2B customer exists / does not exist, Shipping country, Shipping province, Shipping zip/postal code, Shipping city, Selected shipping option title, Delivery method type, Shipping 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 products, Line item product title, Cart attribute key and value, and Customer tags.

B2B order review: Cart subtotal, Cart attribute key and 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.

Condition set Conditions
1 Cart products, Cart total, Cart subtotal, Cart attribute key and value, Line item price ends in, Customer has an account, Customer tags, B2B customer exists / does not exist, Shipping country, Shipping province, Shipping zip/postal code, Shipping zip/postal codes, Shipping city, Shipping address (line 1) regex, Shipping address (line 2) 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, All line items product tags, Quantity of items with product tags, Line item product type, All line item product types, Line item variant title, Line item product title, All line item variant titles, All line item product titles, Cart total, Cart subtotal, Number of line items, Number of items, A line item subscription exists / does not exist, Customer tags, Shipping country, Shipping province, Shipping zip/postal code, Shipping city
3 Company location metafield, Company metafield, Shipping province, Shipping zip/postal code, Shipping zip/postal codes, Shipping city, Delivery cost, Total cart weight (kg)
Function Condition set Conditions
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 and 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 and value, Cart collections, Quantity of items in collections, Individual product quantity in collection, Total value of items in collections, 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 and 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 and value, Line attribute key, Line attribute key and value, Line attribute key and 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, Quantity of items in collections, Quantity of unique variants in collections, 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 and value, Total cart weight (kg), Customer tags, User is a customer, User is authenticated as a customer, Cart attribute key and value, Shipping country
2 Customer metafield, Company metafield, B2B customer exists / does not exist, Number of items
Volume discount, Spend tiers, Group price, Combo discount, Buy X get Y, Flex discount – Cart subtotal, Cart products, Cart collections, Quantity of items in collections, Quantity of unique variants in collections, Total value of items in collections, Number of items, Number of line items, Cart has items on sale, Cart currency, Quantity of variants, Quantity of items with product tags, Line item product tags, Line item product type, Line item vendor, Customer tags, User is a customer, B2B customer exists / does not exist, Is POS checkout, Is not POS checkout, POS location ID
Code rules – Cart subtotal, Cart products, Cart collections, Quantity of items in collections, Quantity of unique variants in collections, Total value of items in collections, Number of items, Number of line items, Cart has items on sale, Quantity of variants, Quantity of items with product tags, Line item product tags, Customer tags, User is a customer, B2B customer exists / does not exist, Customer’s order count, Buyer’s country

These have no condition sets. See volume discounts and code rules.

On Order discount Condition 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 condition lets you type any namespace and key.

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

Function Condition set Conditions
Checkout blocker 1 Cart products, Number of items, Number of line items, Quantity of items with a subscription, Subtotal of line items with a subscription, Line item product type, Line item product tags, 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 and 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 and value, Line attribute missing on product type, Cart contains both subscriptions and one time purchases, Quantity of variants
3 Cart subtotal, Shipping zip/postal code, Shipping zip/postal codes, Shipping city, Shipping country, Shipping province, Selected shipping option title
4 Cart attribute key and value (up to 5 different keys)
Address blocker – Total cart weight (kg), Shipping address 1, Shipping address 2, Shipping country, Shipping province, Shipping zip/postal code, Shipping zip/postal codes, Shipping city
Function Condition set Conditions
Line item price changer 1 Cart total, Cart products
2 Cart total, Cart products, Cart attribute key and value, Customer tags, Customer metafield
Multi line item price changer – Cart total, Cart products, Cart attribute key and value, Customer metafield, Customer tags, B2B customer exists / does not exist, Quantity of variants

These conditions 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
  • Shipping address (line 1) regex, Shipping address (line 2) regex, Delivery cost, Delivery method type
  • Line item price ends in
  • Subscription quantity conditions and Cart contains both subscriptions and one time purchases

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

  • Customer tags: comma list; passes if the customer has any of the tags.
  • Shipping 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.
    • 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.
  • Shipping city on payment and shipping methods: comma list; the whole city name must match, ignoring capitals.
  • Shipping country, Shipping province on payment and shipping methods and shipping discounts: one country or province code per condition.
  • POS location ID: comma list of location IDs. Each has to be the location’s whole ID: 12 doesn’t match location 123.
  • Customer metafield and Company metafield with is more than / is less than, on discounts: numbers compare as numbers. Text compares as text, so dates written like 2026-11-01 compare in date order.
  • Cart currency: comma list of currency codes, such as EUR, GBP, with is one of or is not one of.
  • Line item product type, Line item vendor on volume, combo, Buy X get Y and flex discounts: add each product type or vendor on its own, so a name with a comma like Acme, Inc. stays one name; passes when any item in the cart has one of them, ignoring capitals.
  • Cart attribute key and value with is more than / is less than: compares numbers, so 10 is more than 9. Use it only for numbers. Line attribute key and value on discounts compares numbers the same way.
  • Shipping address (line 1) regex and (line 2) regex: a regular expression, case-sensitive unless you start it with (?i). Leave out JavaScript’s slashes and flags: write (?i)\bp\.?\s*o\.?\s*box\b, not /\bp\.?\s*o\.?\s*box\b/i. To check both address lines, add both conditions to one group.

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 and value can check them directly.