Skip to content

Fix configurable product Add To Cart API with superAttribute #569#582

Open
rohansingh754 wants to merge 1 commit intobagisto:mainfrom
rohansingh754:configurable-add-to-cart-super-attribute
Open

Fix configurable product Add To Cart API with superAttribute #569#582
rohansingh754 wants to merge 1 commit intobagisto:mainfrom
rohansingh754:configurable-add-to-cart-super-attribute

Conversation

@rohansingh754
Copy link
Contributor

### 🐞 Bug Fix: Configurable Product Add To Cart with Super Attributes

This PR fixes an issue where configurable products could not be added to the cart via the Add To Cart API when `super_attribute` was provided.

---

### ❌ Problem
When calling the Add To Cart API (`/api/checkout/cart/add`) for a configurable product and passing `super_attribute`, the API fails to resolve the correct child product.

As a result, the API returns the following error:

```json
{
  "errors": [
    {
      "message": "Options are missing for this product."
    }
  ]
}

This happens because the API does not dynamically match the selected super_attribute options with the corresponding configurable child product.


✅ Solution

  • Dynamically maps the provided super_attribute (attribute_id => option_id).
  • Iterates through configurable product indexes.
  • Matches all selected super attributes against available child product combinations.
  • Correctly identifies and assigns the selected configurable option.

This solution works for:

  • Any number of configurable attributes (e.g. size, color, material, etc.)
  • Both increased or reduced attribute sets
  • GraphQL and REST Add To Cart APIs

📌 Related Issue

Fixes #569


🧪 Impact

  • Fixes configurable Add To Cart API behavior
  • No breaking changes
  • Backward compatible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configurable product Add To Cart API not working properly with superAttribute option.

1 participant