Quirk/bug? - Cart item (bundle) quantity increase

In testing my bundles app, I discovered a quirk/bug, which I wanted to run by the community in case I was missing something.

When increasing the quantity of a bundle product in the cart and/or drawer, after a certain quantity, I get an error stating only x quantity can be added to the cart. which is less than the available inventory?!?!

Specifically, my 2-item custom bundle product has an inventory of 12, with three components (A, B, C) having inventory of 8, 8, and 9 respectively. When building my bundle, I have two selections, and set each selection to component A. In the cart drawer, I then test by increasing the line item quantity pressing the + button, which correctly increments to quantity 4 (component A inventory 8 / 2 selections = 4).

If I then attempt to increment the line item quantity again to 5, I get an error message that I can only add quantity 3 to the cart?!?!? Where did 3 come from?

I checked my cart transform function and there are no errors. I checked the cart JSON via the Cart API, no errors there either. I believe the sections within the cart drawer are rendered by the Section Rendering “API”, so where is it getting a maximum quantity of 3 from?

I am testing with the Dawn theme, so I reviewed the liquid code for the cart drawer, and found the following lines relating to the quantity input:

<input
  ...
  {% if item.variant.quantity_rule.max != null %}
  max="{{ item.variant.quantity_rule.max }}"
  {% endif %}
  ...
</input>

I can confirm I do not have any quantity rules configured, so the input element will not have a max attribute set. I’m puzzled as to where the maximum quantity 3 is coming from?

Any input/feedback/guidance would be greatly appreciated.

Did some more troubleshooting, still having some quirky issues. I did some debugging with my browser’s debug tools in order to share some code.

As per my initial post, I am able to add quantity 4 of my custom bundle to the cart by clicking the plus button in the cart drawer. Doing so yields the following:

Request

{
  "line": "1",
  "quantity": 4
}

Response

{
  "item_count": 8,
  "items": [
    {
      "id": bundle_variant_id,
      "quantity": 4,
      "variant_id": bundle_variant_id,
      "product_id": bundle_product_id,
    }
  ],
  "items_added": [
    {
      "product_id": component_product_id,
      "variant_id": component_variant_id,
      "quantity": 1
    }
  ],
  "items_removed": []
}

I then proceed to increase the quantity in the cart drawer from 4 to 5, which yields the following:

Request

{
  "line": "1",
  "quantity": 5
}

Response

{
  "item_count": 6,
  "items": [
    {
      "id": bundle_variant_id,
      "quantity": 3,
      "variant_id": bundle_variant_id,
      "product_id": bundle_product_id,
    }
  ],
  "items_added": [
    {
      "product_id": component_product_id,
      "variant_id": component_variant_id,
      "quantity": 1
    }
  ],
  "items_removed": []
}

Notice how the change request was for quantity 5 (a total of 10 items), yet the response is item_count: 6 and quantity: 3?!?!?

  • Why is the server responding with a different quantity than requested?
  • Why isn’t the server responding with something line “insufficient quantity”, or the vague “this item is already sold out”?