POST /cart/add.js inconsitent if it's FormData or Json

Hi,

I am developping a custom theme app extension (a cart drawer), and this morning something REALLY weird happened to my customers.

Basically, the /cart/add.js endpoint let customers submits product even if stock control is enabled and product is sold out. But only if it’s form data for unkownn reason.
Here is a proof:

As you can see, the first fetch using json fails as it should. But the second will magically work! Why? Do stock control applied only with json? Sounds weird to me.

hi,

  1. you’re using the Shopify /cart/add.js endpoint

  2. when using JSON (Content-Type: application/json), it correctly enforces max quantity and stock limits

  3. when using FormData (traditional form POSTs), it bypasses stock restrictions, even if the product is sold out or maxed out

try this:

await fetch('/cart/add.js', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    items: [
      {
        id: variantId,
        quantity: 1,
      },
    ],
  }),
});

avoid using FormData for cart mutations unless absolutely necessary, and never use it when inventory integrity is critical