Set a cart attribute
Set a cart attribute is an automation that saves a key and value on the cart when your rules pass, such as payment-type: manual. Shopify copies cart attributes to the order. Use it to tag orders, or to let something else act on what only checkout can see:
- Discounts and checkout rules made with Checkout Buddy can check a cart attribute, so a discount can depend on the payment method, a form answer or the time of day. See use block conditions in a function.
- Shopify Flow and other apps read it as an order attribute.
Requires: Shopify Plus and the Buddy plan.
Set it up
Section titled “Set it up”- In Checkout Buddy, go to Customizations → Content → Create customization → Set a cart attribute.
- Under What it does, enter the Key, such as
gift_wrap, and the Value, such asyes. - Choose when it acts, add your rules under Which checkouts, and an optional message.
- Publish it, save, and make sure a Content app block is in one of checkout’s sections. See where it runs.
The attribute is saved on the order, under Additional details, even keys starting with _. Discounts, checkout rules and other apps can read it.
When it acts
Section titled “When it acts”It starts as Keep it that way · Leave it: the attribute is set whenever the rules pass, and set again if something changes it.
| Choice | For this automation |
|---|---|
| Once per checkout | Set the first time the rules pass |
| Each time the rules start to pass | Set again after the rules stopped passing and pass again |
| Keep it that way | If the buyer, another app or a block changes it, it’s set again |
| Leave it | When the rules stop passing, the attribute keeps its value |
| Undo it | When the rules stop passing, the attribute is removed, unless something else changed it since |
Examples
Section titled “Examples”| You want | Key and value | Rules | When the rules stop passing |
|---|---|---|---|
| A discount for manual payments | payment-type · manual |
Payment method · is any of · Manual payment (bank deposit, money order) | Undo it |
| Tag pickup orders for your team | pickup · yes |
Delivery method · is any of · Pickup in store | Undo it |
| Tag first orders for Shopify Flow | first-order · yes |
Customer · is · On their first order | Leave it |
Things to know
Section titled “Things to know”- Two automations setting one key to different values fight each other when both rules pass. The editor warns you; give them rules that can’t pass at the same time.
- Its rules can check the same key, such as “set it only while it’s empty”. That’s fine on purpose, but with Undo it it can go back and forth until the brake stops it, and the editor warns you.
- Undo removes the key, rather than leaving it empty, so a rule that checks whether the key has a value sees it gone.
- The attribute is only set once the buyer reaches a step with the app block. Buyers who pay with Apple Pay or Google Pay from the cart skip checkout.
- Custom fields answers are cart attributes already, under each field’s key, so a function can check them without an automation.
