Skip to main content

Command Palette

Search for a command to run...

Why Shopify cart attributes don't show up on the order page (and how I fixed it)

Updated
โ€ข4 min readโ€ขView as Markdown
Why Shopify cart attributes don't show up on the order page (and how I fixed it)

TL;DR ๐Ÿ›’

If your Shopify cart attributes are empty in /cart.js or missing on the order page:

  1. Add the input with name="attributes[your-key]" on the cart page

  2. Check saved values at {your-store-url}/cart.js

  3. On every AJAX cart update (cart/update.js or cart/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 min and max.

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:

  1. Open {your-store-url}/cart.js in your browser

  2. Look at the attributes field 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/change or cart/update replaces the cart state

  • Shopify 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.js early โ€” don't wait until orders come in

  • Any 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. ๐Ÿ™‚