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

Search for a command to run...

No comments yet. Be the first to comment.
I didn't think I could ship a web app within a week. Then something happened on a train that changed that. This is the story of how I built and shipped Roka โ and what AI actually made possible. The

Intro I set up Biome for a small Next.js app and felt great about it. Then I realized a few days later that the class name sorting I'd configured wasn't doing anything - and the reason was... embarras
Creating Shopify Theme with AI - #4

Creating Shopify Theme with AI - #3

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 page
Check saved values at {your-store-url}/cart.js
On every AJAX cart update (cart/update.js or cart/change.js), resend the attributes โ Shopify drops them if you don't
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.
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.
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.js in your browser
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.
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 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. โ
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
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
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. ๐