Adding line item properties to products affected by a cart transform function

I have a cart transform function that uses the merge operation and I need to add line item properties to the bundle or one of the items in the bundle but neither seems possible.

Using applyCartLinesChange on the cart line item is successful but the line item does not appear in the order when viewed in the admin.

Using it on the bundle line item doesn’t work at all.

Applying changes to the bundle line item:

Applying properties to the only line item in the cart:

Is there a proper way to apply line item properties to transformed line items in this case?

You can add line item properties to the shell product that you merge lines into as part of the merge operation - something like the below should work.

 const mergeOperation = {
      cartLines: Object.values(groupedlines).filter(line => !!line).map(line => ({ cartLineId: line.id, quantity: bundleQuantity })),
      parentVariantId: "gid://shopify/ProductVariant/123",
      title: "Custom BundleTitle",
      price: {
        percentageDecrease: {
          value: 15
        }
      },
      attributes: [
       {
         key: "_box_id",
         value: `1234`,
       },
       {
         key: "_box_discount",
         value: `20%`,
       },
       {
         key: "_box_size",
         value: `20`,
       }
      ]
    }; 

I think the only way to add them to the actual components within a cart transform is to use the lineExpand operation instead and then you can access the attributes at a line level via expandedCartItems - Cart Transform Function API

Interesting, wonder how it would work when adding properties through the checkout UI.

I’ve opted out of using the cart transform function and started using the new parent_id field instead.