Skip to content

Add grouped product with individual quantity to cart using rest api #26909

Closed
@manish-sirvi

Description

@manish-sirvi

Summary (*)

Currently i'm using POST /V1/carts/mine/items rest api endpoint to add products to carts.
So for grouped product if use the payload as mentioned in devdoc then this picks the default quantity which is used in adminhtml to add those products to cart.

So if i want to add custom quantity for each product to add to cart, i am unable to use "product_option" in payload for grouped product to specify individual quantity as i do for other product types.

Examples (*)

This is the payload mentioned on swagger for above api to add products to cart.

{
"cartItem": {
"item_id": 0,
"sku": "string",
"qty": 0,
"name": "string",
"price": 0,
"product_type": "string",
"quote_id": "string",
"product_option": {
"extension_attributes": {
"custom_options": [
{
"option_id": "string",
"option_value": "string",
"extension_attributes": {
"file_info": {
"base64_encoded_data": "string",
"type": "string",
"name": "string"
}
}
}
],
"bundle_options": [
{
"option_id": 0,
"option_qty": 0,
"option_selections": [
0
],
"extension_attributes": {}
}
],
"configurable_item_options": [
{
"option_id": "string",
"option_value": 0,
"extension_attributes": {}
}
],
"downloadable_option": {
"downloadable_links": [
0
]
},
"giftcard_item_option": {
"giftcard_amount": "string",
"custom_giftcard_amount": 0,
"giftcard_sender_name": "string",
"giftcard_recipient_name": "string",
"giftcard_sender_email": "string",
"giftcard_recipient_email": "string",
"giftcard_message": "string",
"extension_attributes": {}
}
}
},
"extension_attributes": {
"negotiable_quote_item": {
"item_id": 0,
"original_price": 0,
"original_tax_amount": 0,
"original_discount_amount": 0,
"extension_attributes": {}
}
}
}
}

How am i supposed to add grouped product with individual quantity specified for the products in group product.

Proposed solution

There should be another key in "product_option" for grouped products to specify quantity.
Well if i use PUT /V1/carts/mine/items endpoint to update the quantity for products using item id after adding them, then i get the desired result.
So this approach is difficult to follow on mobile end and is also very slow.

Metadata

Metadata

Assignees

Labels

Component: ApiUse with concrete module component label E.g. "Component: Api" + "Catalog"Component: GroupedProductFixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: doneReproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S2Major restrictions or short-term circumventions are required until a fix is available.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions