For the complete documentation index, see llms.txt. This page is also available as Markdown.

Examples

Ready-to-use function examples — order limits, address rules, tag-based restrictions, delivery and payment customizations.

Each example lists the category (which folder to create the function in), the family to pick, and any variables to set. Copy the code into the Functions Console editor, adjust, save and turn the function on.

All money values arrive in the presentment currency — what the buyer sees and pays at checkout. currencyCode is selected once per input; every amount in the same run shares that currency.

Validation

Order value limit with a configurable threshold

Blocks checkout when the cart total exceeds a limit the merchant can edit on the dashboard — no code changes needed.

Category: Cart and checkout validation · Family: General

Function variables (the Function button in the editor toolbar):

{
  "short_text#MAX_ORDER_TOTAL": "500",
  "metadata": {
    "MAX_ORDER_TOTAL": {
      "subtype": "number",
      "helpText": "Orders above this total are blocked at checkout"
    }
  }
}

Code:

Currency-aware order limit

Applies the limit only when the buyer checks out in a specific currency.

Category: Cart and checkout validation · Family: General

To enforce a limit across all currencies, define per-currency thresholds in a json function variable (e.g. { "USD": 500, "EUR": 450 }) and look up vars.LIMITS[total.currencyCode] in your code.

Block PO boxes in the shipping address

Category: Cart and checkout validation · Family: Address

The error appears directly under the address field thanks to the target — see error targets.

Require login to buy gift cards

Category: Cart and checkout validation · Family: General

Quantity limit for tagged products

Limits products carrying a specific tag to 2 units per order.

Category: Cart and checkout validation · Family: Product

Query variables (the Query button in the editor toolbar):

Code:

Wholesale-only bulk orders

Requires a customer tag for quantities above 100.

Category: Cart and checkout validation · Family: Customer

Query variables: { "hasCustomerTags": ["wholesale"] }

Delivery customization

Hide express shipping for heavy carts

Category: Delivery customization · Family: General

Rename a delivery option for loyal customers

Category: Delivery customization · Family: Customer

Payment customization

Hide Cash on Delivery for B2B buyers

Category: Payment customization · Family: Customer

Move a preferred payment method to the top

Category: Payment customization · Family: General

Discounts

10% off products with a tag

Category: Discounts · Family: Product

Query variables:

Code:

Order discount above a threshold

Category: Discounts · Family: General — set MIN_ORDER_TOTAL and ORDER_DISCOUNT_PERCENT as code variables.

The discount function's title is shown to buyers at checkout as the discount name.

Cart transform

Merge tagged products into a bundle

Category: Cart transform · Family: Tags

Query variables:

Code — set BUNDLE_PARENT_VARIANT_ID as a code variable (an existing, published variant that represents the bundle):

Time-based rules

Block checkout outside business hours

Category: Cart and checkout validation · Family: Time

Query variables:

Code:

timeAfter / timeBefore arrive as pre-computed booleans against the shop's local time — your code never parses dates. See Families and Variables for the date-time variants.

Last updated