Use block conditions in a function
What you’ll build: an order discount that applies only when the customer selects a manual payment method (such as bank transfer). Order discounts can’t see the payment method, but checkout can.
Requirements: Buddy plan and Shopify Plus (for the automation).
How it works
Section titled “How it works”Checkout’s rules can check far more than functions can: the selected payment type, dates and times, form answers, whether the checkout has a note, and more. See Content rules and conditions for functions.
The trick is to pass the answer along:
- A Set a cart attribute automation, with the rules you need, sets a cart attribute when they pass.
- The function checks for that attribute with a Cart attribute key and value condition.
-
Create the automation. In Checkout Buddy, open Customizations. On the Content tab, click Create customization and choose Set a cart attribute.
- Key:
manual-payment - Value:
yes - When the rules stop passing: Undo it, so the attribute is removed when the buyer switches to another payment method.
- Which checkouts: Only checkouts that match the rules, Payment method, is any of, Manual payment (bank deposit, money order).
- Turn on Published and save.
- Key:
-
Place it. It’s invisible, but the Content app block must be in checkout for it to run. Add one on the payment step in the Checkout Editor, or anywhere on every step, such as the order summary, and save the editor.
-
Create the function. For example, an Order discount with Condition set 1 and the condition Cart attribute key and value: key
manual-payment, is equal to, valueyes. -
Test it. Select bank transfer and watch the discount apply; switch to card and it’s removed.
Which functions can read cart attributes
Section titled “Which functions can read cart attributes”| Function | Can read cart attributes |
|---|---|
| Hide / rename / reorder payment method | Condition set 1 only |
| Hide accelerated checkout payment methods | Yes |
| Hide / rename / reorder shipping method | Condition set 1 only |
| Order discount, order discount code | Condition set 1 only |
| Collection discount, collection discount code | Condition set 1 only |
| Shipping discount | Condition set 1 only |
| Product discount, product discount code | No. Use a line attribute condition, or an order or collection discount |
| Volume, spend tiers, group price, combo, Buy X get Y and flex discounts, code rules | No |
| Checkout blocker | Condition sets 1 and 4 |
| Address blocker, purchase limits | No |
| B2B order review | Yes |
| Line item price changer | Condition set 2 only |
| Multi line item price changer | Yes |
Things to know
Section titled “Things to know”- One key per function. A function reads only one cart attribute key (a checkout blocker on Condition set 4 reads up to five). Use the same key in all of that function’s attribute conditions: the editor warns under a condition on another key.
- Keys and values must match exactly, including capitals.
- Choose “Undo it”. With Leave it, the attribute stays set after the rules stop passing, and the function keeps acting on it.
- The customer must reach the app block. The attribute is only set once a step with the Content app block has loaded. Put it on the step where the condition can change, or earlier.
- Form fields work too. Every Custom fields answer is already a cart attribute, under the field’s key, so a function can check form answers directly.
- More on the automation: Set a cart attribute.
With an older Apply checkout attribute block
Section titled “With an older Apply checkout attribute block”An Apply checkout attribute block made before the Content block does the same job. It shows in a Checkout Buddy (v1) app block with its ID in Fixed block ID, and needs Clear attribute value when hidden ticked to remove the attribute when its conditions stop passing. See Apply checkout attribute.

