How to Add a Gift Message Field to Shopify Cart Without an App
Adding a gift message field to your Shopify cart lets customers type a note ("Happy birthday, Maya — from the whole team") at checkout, and that note rides along with the order into your admin and notification emails. You can build it with Shopify's native cart attributes and a small Liquid edit — no app subscription, no third-party script slowing down your store.
Why Add a Gift Message Field (and Why Skip the App)
Gift messaging matters most for stores selling physical goods that get shipped to someone other than the buyer: candles, jewelry, chocolates, flowers, baby gifts, coffee subscriptions. When a customer can't add a note, they either email you separately (which you have to manually match to an order) or abandon the gift idea entirely.
Apps that add gift options exist — Gift Note, Gift Wrap, and similar tools in the Shopify App Store — and they work fine. But most charge a monthly fee, and many inject JavaScript into your cart and checkout flow. For a single text field, that's a lot of overhead: an extra script to load, an extra vendor to trust with customer data, and a recurring cost for something Shopify already supports natively.
The native approach uses cart attributes: key-value pairs you attach to a cart that persist through checkout and appear on the resulting order. Shopify stores them automatically, shows them in the admin order page, and includes them in order notification emails if you add the right Liquid. No app, no monthly fee, full control.
The trade-off: you're editing theme code, so you need to be comfortable with Liquid or willing to follow instructions carefully. And you'll need to re-check the field after theme updates if your theme replaces cart templates.
What You'll Need Before You Start
- A Shopify plan that allows theme code editing (all standard plans do).
- Theme access. Go to Online Store → Themes → your live theme → the three-dot menu → Edit code.
- A duplicate of your theme. Always duplicate before editing. If something breaks, you publish the copy and you're back in business.
- Knowledge of which cart your theme uses. Most modern themes (Dawn, Refresh, Craft, Sense) use a cart drawer or a cart page built from
sections/main-cart-items.liquidorsnippets/cart-drawer.liquid. Older themes may usetemplates/cart.liquid. Search your theme files for<form action="/cart"to find the right one. - A test product and a test order. You'll want to place a real test order (or use Shopify's Bogus Gateway in test mode) to confirm the message flows through.
Step 1: Add the Gift Message Field to Your Cart Form
Find the cart form in your theme. In Dawn and most Shopify OS 2.0 themes, open sections/main-cart-items.liquid. You're looking for the <form> element with action="{{ routes.cart_url }}" and method="post".
Inside that form — before the checkout button, ideally after the line items — add a labeled textarea:
<div class="gift-message">
<label for="gift-message">Add a gift message (optional)</label>
<textarea
id="gift-message"
name="attributes[Gift message]"
maxlength="200"
placeholder="e.g. Happy birthday! Love, Sam"
></textarea>
</div>
The critical part is name="attributes[Gift message]". The attributes[...] syntax is what tells Shopify to save this as a cart attribute rather than ignoring it. The text inside the brackets becomes the label you'll see on the order.
If your theme uses a cart drawer, you'll need to add the same field to the drawer's form in snippets/cart-drawer.liquid — otherwise customers who never visit the full cart page won't see it. Some themes let you disable the drawer entirely in theme settings; if you do that, the cart page field is enough.
Important: if your theme submits the cart via AJAX (Dawn's cart drawer does), the attribute may not save unless the form includes it in the fetch request. Check whether the theme's cart JavaScript sends new FormData(form) — if so, the textarea is included automatically. If the script builds its own payload, add the attribute to it manually.
Step 2: Capture the Message with Cart Attributes in Liquid
Once the field is in the form, Shopify handles storage. But you should confirm the attribute is actually present and handle the empty case gracefully.
On the cart page, you can display the saved message back to the customer so they can verify it before checkout:
{% if cart.attributes['Gift message'] != blank %}
<p class="cart-attribute__gift">
<strong>Gift message:</strong> {{ cart.attributes['Gift message'] }}
</p>
{% endif %}
This is optional but useful — it confirms to the shopper that their note was captured. Place it near the cart totals or above the checkout button.
If you want the field to be required when a "This is a gift" checkbox is ticked, add a small script that toggles the required attribute on the textarea. Keep it simple: a checkbox with name="attributes[Is gift]" and value="Yes", plus a few lines of JavaScript that show or hide the textarea.
One caution: cart attributes are not line-item properties. If a customer adds three products and one gift message, the message applies to the whole order, not a specific item. For per-item gift notes, you'd need line item properties instead — a different (and more complex) implementation. For most small stores, order-level gift messaging is what customers expect.
Step 3: Display the Gift Message on Orders and Emails
Cart attributes automatically appear on the order in your Shopify admin, under the order's Additional details section. You don't need to do anything for that.
For order confirmation and notification emails, you need to edit the email templates. Go to Settings → Notifications → Order confirmation (and any other templates where you want the note, such as New order for staff). Add this Liquid where you want the message to appear:
{% if attributes['Gift message'] != blank %}
<p><strong>Gift message:</strong> {{ attributes['Gift message'] }}</p>
{% endif %}
The variable is attributes (not cart.attributes) inside email templates. If you're on Shopify's newer email editor, you can add this via the code view of the template.
For packing slips and invoices, edit the template under Settings → Notifications → Packing slip and add the same block. This is the one your fulfillment team actually reads, so it's worth doing.
If you use a third-party fulfillment app or a 3PL, check whether it reads order attributes — most do, but confirm before relying on it.
Step 4: Style the Field to Match Your Theme
The textarea will inherit some theme styles, but it usually needs a little help. Add CSS to your theme's base.css or component-cart.css (Dawn) — or use the Custom CSS box in the theme editor if your theme supports it.
Match your theme's existing form fields: same border radius, border color, font size, and padding. A few practical rules:
- Set
width: 100%and amin-heightaround 80–100px so it's clearly a message box, not a single-line input. - Use the same
font-familyandfont-sizeas your other inputs — copy the selector from an existing quantity or note field. - Add a visible
:focusoutline so keyboard users can see where they are. - Keep the label above the field, not as a placeholder only — placeholders disappear when typing and fail accessibility checks.
Test on mobile. The cart drawer is narrow on phones; a textarea that's fine on desktop can look cramped at 375px wide. Check that the field doesn't push the checkout button off-screen.
Testing Your Gift Message Field Before You Launch
Run through this checklist on a duplicate theme before publishing:
- Add a product, open the cart, type a message, proceed to checkout. Confirm the message appears in the order's Additional details in admin.
- Test with an empty message. The order should still go through, and no "Gift message:" line should appear in emails.
- Test the cart drawer and the cart page (if your theme has both) to confirm the field appears in each.
- Place a test order and check the confirmation email for the message block.
- Check the packing slip in admin.
- Test on mobile at 375px and 414px widths.
- Check the character limit — try pasting 250 characters into a 200-character field and confirm it truncates cleanly.
Common Pitfalls and How to Fix Them
| Problem | Likely cause | Fix |
|---|---|---|
| Message doesn't appear on the order | Field is outside the cart <form>, or name is missing attributes[...] |
Move the textarea inside the form and check the name attribute exactly |
| Field appears but message is blank on order | Theme's AJAX cart script builds its own payload and drops the field | Add the attribute to the script's fetch body, or switch the cart to standard form submission |
| Message shows in admin but not in emails | Email template not edited | Add the attributes['Gift message'] block to each notification template |
| Field disappears after a theme update | Theme update overwrote the edited template | Keep a record of your edits; reapply after updates, or move the field to a section your theme won't overwrite |
| Field shows on cart page but not in drawer | Only one cart template edited | Add the field to both main-cart-items.liquid and cart-drawer.liquid |
| Customers can't tell if the message saved | No confirmation shown | Display the saved attribute back on the cart page |
A few more things worth knowing:
- Cart attributes are stored per cart, so if a customer empties their cart, the message goes with it. That's usually fine, but mention it in your FAQ if gift messaging is a core feature.
- If you later migrate to a new theme, plan to rebuild the field. It's a 15-minute job once you've done it once.
- Don't use the field for anything that needs to affect pricing (like gift wrap fees) — attributes don't change the cart total. For paid gift wrap, use a product variant or a line item property instead.
Conclusion
A native gift message field takes about 20 minutes to build and costs nothing per month. You're using Shopify's cart attributes — a feature that's been stable for years — and adding a textarea, a display block, and an email template edit. The result is cleaner than most gift apps and fully under your control. Duplicate your theme, make the edits, run the test checklist, and you're done.
FAQ
Will the gift message field work with Shopify's one-page checkout? Yes. Cart attributes carry through checkout automatically — the checkout itself doesn't need editing, and the message appears on the order in admin once the order is placed.
Can I make the gift message required only when a customer checks a "This is a gift" box?
Yes, with a small amount of JavaScript that toggles the required attribute on the textarea based on the checkbox state. Keep the checkbox as a separate cart attribute (e.g., attributes[Is gift]) so you can see it on the order too.
Does this work if I use a third-party checkout or a headless storefront? Cart attributes are a Shopify platform feature, so they work with the standard checkout. If you're headless (Hydrogen, custom storefront), you'll need to pass attributes through the Storefront API's cart mutations — check Shopify's current API docs for the exact syntax.