New Shopify Certification now available: Liquid Storefronts for Theme Developers

Post an order with a variant with components (New bundle functionality)

Solved
kansasauctions
Shopify Partner
4 0 1

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?

Accepted Solution (1)
Liam
Shopify Staff
Shopify Staff
1917 204 579

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:

  • 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.

 

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

View solution in original post

Replies 4 (4)
Liam
Shopify Staff
Shopify Staff
1917 204 579

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:

  • 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.

 

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

kansasauctions
Shopify Partner
4 0 1

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?

akshuklait-92
Shopify Partner
2 0 0

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. 

  • Break down the bundle into its constituent products, and add each one as a separate line item in the order.

> can u plz share any example of order post data for these types of items? 
waiting for your prompt response. thanks 

marnau
Shopify Partner
3 0 0

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?