Unexpected behaviour from AJAX Add to Cart API

Hi,

I’m also experiencing strange ajax behavior. The ajax cart-add api returns 422, but still adds the items.

I’ve even managed multiple times (although cannot reliably replicate it) to add a product again and the ajax api does add up the quantity. But instead it returns 2 items with the exact same item.id, qty, variant_id and even key!

The only difference I can see is that an automatic discount applies differently to both items.

One says:

“discounts”: [
{
“amount”: 76,
“title”: “10kroff”
},

The other:

“discounts”: [
{
“amount”: 77,
“title”: “10kroff”
},

This discount is an order-level discount with fixed amount, so it seems to be correctly divided onto those items. Except that these items should have been merged by the ajax api.