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?
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:
Instead of trying to order the parent variant (the one with components), you can order its components individually
Break down the bundle into its constituent products, and add each one as a separate line item in the order.
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.
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?
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?
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.