Updating Composite Products
Updating Composite Products
The composite components of a product are updated by sending a PUT
request to the https://<<domain_prefix>>.retail.lightspeed.app/api/2.1/products/{product_id}
endpoint.
The {product_id}
can be that of either a standard or composite product, but not a variant product.
If it is a standard product, the act of updating it to have composite components will convert it into a composite product.
The products used as the composite components need to already exist.
These components can be either standard or variant products, but they cannot be composite products.
WARNING: An important thing to remember is that any product used as a composite component cannot be deleted. Before that product can be deleted, it needs to be removed from all composites it is in or those composites need to be deleted.
Updating the composite components of a product
Let's say we have an existing composite product (this would also work if it were a standard product) that we want to update.
It has the following ID:
9d07e5b8-3f18-4733-a528-5b510640a2ab
In addition, we have two existing standard products (this would also work if they were variant products) that we want to use as components.
They have the following IDs:
028f8492-636f-4c95-b11c-650a43cad10c
162a2294-cbba-46bf-8069-b86d0381193e
The minimal payload should look like this:
PUT https://<<domain_prefix>>.retail.lightspeed.app/api/2.1/products/9d07e5b8-3f18-4733-a528-5b510640a2ab
{
"details": {
"composite_components": [
{
"product_id": "028f8492-636f-4c95-b11c-650a43cad10c",
"quantity": 3
},
{
"product_id": "162a2294-cbba-46bf-8069-b86d0381193e",
"quantity": 2
}
]
}
}
IMPORTANT:
composite_components
is the full list of composite components which means that, when updating a composite product, they will replace all of the components on the composite.
Updated 2 months ago