
TL;DR 🛒
If your Shopify cart attributes are empty in /cart.js or missing on the order page:
Add the input with
name="attributes[your-key]"on the cart pageCheck saved values at
{your-store-url}/cart.jsOn every AJAX cart update (
cart/update.jsorcart/change.js), resend the attributes — Shopify drops them if you don't
Intro
I added a date picker to my Shopify cart page, checked the order page, and the value was just... gone. No error, no attribute, nothing. 😩
This post is for theme developers who use cart attributes (delivery date, gift message, etc.) and wonder why they never reach the order.
Add a date picker to the cart
I added a date input for the delivery date:
<label for="delivery-date">{{ 'cart.delivery_date' | t }}</label>
<input
type="date"
id="delivery-date"
name="attributes[delivery-date]"
value="{{ cart.attributes['delivery-date'] }}"
min="{{ min_date }}"
max="{{ max_date }}"
/>
Note: I limit the date to a specific range, so the input has
minandmax.
The HTML looked correct. I assumed the value would show up on the order page after checkout. It didn't.
How to check what's in the cart
After I released the change, orders in the admin didn't show the delivery date at all.
At first, I thought customers were skipping it because of the date range. (No delivery date = fastest shipping.)
But I needed to know if the feature was working. So I started digging — and it turned out the value probably wasn't being sent to the cart at all.
The easiest way to check whether an attribute is saved:
Open
{your-store-url}/cart.jsin your browserLook at the
attributesfield in the JSON response
This shows what Shopify will actually send to checkout.
My result:
"attributes": {}
Oops 🙊 — empty. The attribute never made it into the cart object.
The problem
My cart page has a quantity input. Whenever a customer changes the quantity, the theme calls cart/change.js or cart/update.js via AJAX.
From what I could tell, this is what caused my bug:
Any AJAX call to
cart/changeorcart/updatereplaces the cart stateShopify only keeps the attributes you send in that same request
If you don't include them, they're dropped — not delayed, not cached. Gone
So even though the date picker had the right name, a later cart update wiped the attribute. That's why /cart.js showed "attributes": {}.
The fix: save attributes on every cart update
The cart/update.js endpoint accepts an attributes field. I send the attribute value whenever the customer changes the date:
async function saveCartAttribute(key, value) {
const response = await fetch(window.Shopify.routes.root + "cart/update.js", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ attributes: { [key]: value } }),
});
if (!response.ok) {
console.error("Failed to save cart attribute:", response.status);
}
}
document.getElementById("delivery-date")?.addEventListener("change", (event) => {
saveCartAttribute("delivery-date", event.target.value);
});
Important: If your theme already updates the cart on quantity change, make sure that request also includes current attribute values. Otherwise the quantity update will wipe them again.
After adding this, I checked /cart.js again:
"attributes": {
"delivery-date": "2026-05-25",
"delivery-time": "AM"
}
Now the values were actually in the cart. ✅
Check the order page
After the fix, attributes showed up on orders. (Finally got an order with a delivery date! 🎉)
When no date is selected → the order page shows only Note in the top-right
When attributes are entered → an Additional details section appears below Note
What I learned
Next time I work with Shopify cart attributes, I'll check these things first:
Verify with
/cart.jsearly — don't wait until orders come inAny AJAX cart call can wipe attributes — not just quantity changes; line item edits, upsells, or custom scripts can do it too
Resend attributes in every cart update — treat them like form fields you must include on each submit, not set-once values
Conclusion
Cart attributes in Shopify look simple in Liquid (name="attributes[key]"), but they are easy to lose silently. If yours don't show up on the order page, open /cart.js first. If attributes is empty, find every place your theme calls cart/update.js or cart/change.js and make sure attributes are included in those requests.
That one check saved me a lot of guessing. Hope it helps you too. 🙂
Comments
Join the discussionNo comments yet. Be the first to comment.


