How can I get the component prices when using expand operation?

I’m studying the expand examples in the official cart transform doc, but I don’t find them appropriate for my customized bundle use case.

Now I add the bundle parent variant to the cart. Let’s say the bundle parent = variant A + variant B + variant C. But I don’t know which variant A, B, or C the customers want to select. These 3 variants are picked from hundreds or more than a thousand variants from a collection or products.

How can I get the component variant prices? I want the total component prices to calculate the discounted bundle price. The prices are not available in input.graphql. If I store the prices to a metafield. It will lead to a sync issue since the variant prices are subjected to frequent updates. The metafield size can’t store many variants either. This approach is not scalable

If I switch to using a merge operation (i.e. add all bundle components to the cart), I don’t have the bundle discount and bundle conditions on hand. Then I have to store all bundle discounts and conditions into a single metafield for query. However, the validation is not easy. Some users may be able to switch the bundle components into other inapplicable variants.

I find both operations are not easy for custom bundles, e.g. select any 3 variants from a collection. Did I miss anything?

You should be able to add more fields (like prices) to the graphql query

The CartLine of the bundle parent variant has a cost field. But this CartLineCost only has the price of the bundle parent variant but not the bundle components’ prices

Which prices field do you mean?

I think you can request the components themselves via graphql, and include their prices in that request.

No, there is no such field of component under graphql Cart Transform API common objects. Please indicate where it is.

I am not talking about graphql admin API

Doh! Thanks for pointing that out.

I just poked around a bit, and, oh yeah, of course we don’t provide the components, because we don’t know what the components are. That’s what the expand operation is for, to determine what the components are.

I’ve asked one of my colleagues, who is more familiar with this subject, if he has any other ideas. One of us will post it here if we do.

So… are you sure expand is the right operation here? Maybe you need merge instead?

I am not sure which operation is the best because both have some sort of limitations.

Let’s say I use a merge operation and I add the components to the cart. Where can I get the discount for this specific bundle?

I think your doc is wrong for customized bundles. This part states that:

Discount calculated on the parent then allocated on the components.

When I add the components to the cart for a merge operation, the bundle parent is not available so as the discount. What can I do here? I store all bundle discounts to a metafield for query?

And the metafield has a size limitation of 10KB. A store with multiple bundles can easily reach this limit.