Conditional form fields
What you’ll build: a question that reveals a follow-up field depending on the answer. For example, “Is this a gift?” → Yes shows a “Gift message” field.
Requirements: Business plan and Shopify Plus. Radio and Text field blocks are on every plan, but the Free and More Functions plans allow only one block, and this recipe needs two.
How it works
Section titled “How it works”Every form field saves the customer’s answer as a checkout attribute. The attribute’s key is the block’s Name (its first 28 characters), and its value is the answer. A second block can then use the Cart attribute key, value display rule to appear only when that attribute has a certain value.
-
Create the question. Click Create customization and choose Radio.
- Name:
Is this a gift. This becomes the attribute key, so keep it short and don’t rename it later. - Add two options with Label
Yes/No. Also fill in Value (optional) withyesandno: the value then stays the same if you translate the labels. - Save, and note the block’s ID.
- Name:
-
Create the follow-up. Choose Text field.
- Name:
Gift message. Label:Gift message. - In Display rules, choose Show only when rules pass and add Cart attribute key, value:
- Key:
Is this a gift - is equal to
- Value:
yes
- Key:
- Save, and note its ID.
- Name:
-
Place both. In the Checkout Editor, add one Checkout Buddy app block where you want the fields and enter both IDs in Multiple block IDs, for example
41, 42. They’re shown in that order, and the follow-up only appears once its rule passes. See the Checkout Editor. -
Test it in a real checkout: pick Yes and the gift message appears; pick No and it disappears.
Both answers are saved on the order as additional details, under the keys Is this a gift and Gift message.
Example: show a checkbox after a date is picked
Section titled “Example: show a checkbox after a date is picked”- Create a Date field block named
Delivery date. - Create a Checkbox block (for example “Leave at the door if nobody’s home”) with the rule Cart attribute key, value, Key
Delivery date, is not equal to, Value left blank. A blank value with is not equal to means “has any value”. - Place both, as in step 3 above.
Rule values for each field type
Section titled “Rule values for each field type”| Field A is a… | Its saved value | Rule for field B |
|---|---|---|
| Checkbox | true or false |
is equal to true |
| Radio, Select | The option’s value, or its label if no value is set | is equal to the value |
| Multiple checkboxes | Every ticked value, joined with commas | is equal to only works for an exact combination; prefer Radio |
| Text field, Date field | What the customer entered (dates as YYYY-MM-DD) |
is not equal to with a blank value, for “anything entered” |
Things to know
Section titled “Things to know”- Keys and values must match exactly, including capitals and spaces.
- Renaming field A changes its key. Update field B’s rule if you rename it.
- Using your own key. Instead of the Name, you can set a key with Apply effect when value changes → Apply value as checkout attribute → Attribute key. Use that key in the rule.
- Three or more levels work the same way: each field’s rule checks the previous field’s key.
- Hidden fields keep their value. If a customer fills in field B and then changes field A, B disappears but its earlier answer stays saved on the order.
- More on the fields themselves: form fields and choice fields.
