Discussing APIs and development related to customers, discounts, and order management.
I used productVariantRelationshipBulkUpdate to create some product bundles on my development store.
Now I'm trying to post an order through the Admin REST API with a line item containing a variant ID that has components and I get this message:
line_items.variant_id - cannot be a variant with components
I need to still be able to post orders with these variants. Any workaround that doesn't involve removing the components before and re-adding them after every single order I try to post?
Solved! Go to the solution
This is an accepted solution.
Hi Kansasauctions
In the case of product bundles or variants with components, they're usually not meant to be ordered as a single line item. Instead, each component of the bundle should be a separate line item in the order. The error you're seeing is because the API is preventing you from ordering a variant that has been set up as a bundle of other products.
Here's a workaround that doesn't involve removing the components:
This way, you're not directly ordering the variant with components (the bundle), but you're ordering its parts. This should bypass the error you're encountering.
Keep in mind that you'll have to adjust your inventory management processes accordingly, as ordering the components individually may affect your inventory levels for the parent variant.
Hope this helps!
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
This is an accepted solution.
Hi Kansasauctions
In the case of product bundles or variants with components, they're usually not meant to be ordered as a single line item. Instead, each component of the bundle should be a separate line item in the order. The error you're seeing is because the API is preventing you from ordering a variant that has been set up as a bundle of other products.
Here's a workaround that doesn't involve removing the components:
This way, you're not directly ordering the variant with components (the bundle), but you're ordering its parts. This should bypass the error you're encountering.
Keep in mind that you'll have to adjust your inventory management processes accordingly, as ordering the components individually may affect your inventory levels for the parent variant.
Hope this helps!
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Thanks Liam. I was hoping to include the parent for reporting purposes. I notice on orders for product bundles placed through Shopify that the order page shows "Part of:" and the bundle name on each line item. I can't find any indication of how this is accomplished in the JSON or on the API pages. Is this something that I can read / write by API?
Hi @Liam I'm also getting the same issue
Array
(
[error] => Array
(
[line_items.variant_id] => Array
(
[0] => cannot be a variant with components
)
)
)
I can't find any index in product.json that may inform that current item is a bundle product.
> can u plz share any example of order post data for these types of items?
waiting for your prompt response. thanks
Hi,
I'm also interested, as @kansasauctions says, in keeping track of which orders are purchased as a bundle and with aren't. I'm able to create an order by adding the constituent products of a bundle, but this way there's no way to know it was bought as a bundle. How would we go about getting this "part of the bundle X" under each line_item?
Hi ,
do you solve your problem? I meet the same issues.
I wil split the order line with separent sku, but how to show the "part of the bundle X" under each line_item?
if you have any idea,please share to me.thanks very much
Hi @Liam ,
This solution would work fine if you know both that the product you are trying to use to create an order has a relationship, and had a way to access that relationship via the API. Right now, in both the GraphQL and REST API's, products or product variants do not appear to have any type of field denoting that a relationship is present, or what the members of the relationship would be.
Given that the bundling capabilities are something that is provided by Shopify, would it not make sense to either make this relationship data accessible, or automatically add the required line items to the order? The latter would be preferable, as the experience would then be consistent with adding regular variants to an order.