AJAX API - Add items to cart, order of items changed

Topic summary

AJAX cart additions via /cart/add.js show inconsistent line-item ordering, alternating between LIFO (last added appears first) and FIFO (first added appears first). Historically, developers reversed the items array to control order; recent platform-side changes caused the behavior to flip and even oscillate, breaking themes.

Expected behavior per Shopify’s changelog is reverse chronological (LIFO). One user reports Shopify acknowledged and mitigated an issue for them, but others still see server-side inconsistencies across browsers and stores.

Repro evidence includes direct fetch calls and screenshots: adding multiple items results in changed order when fetching the cart. Entering checkout or applying a discount often switches carts to FIFO until the cart/cookie is cleared; sometimes removing items flips back to LIFO unpredictably. Cart Transform apps/bundling can also yield mismatches (cart appears FIFO, checkout shows LIFO).

Workarounds noted: clearing client-side cache/cookies or rebuilding the cart may restore LIFO, but results are unreliable for dynamic sessions.

Status: unresolved/ongoing. Support referenced this as a potential feature request to maintain a consistent order; users are advised to open tickets and reference existing case 43261348. Code snippets and screenshots are central to understanding the issue.

Summarized with AI on December 22. AI used: gpt-5.

Liam - some info on this would be great as it seems to have reverted back to how it behaved prior, once again causing me a ton of chaos.