Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Cart Transform API Merge Operation -- Adding new attributes to cartLines during MergeOperation?

Cart Transform API Merge Operation -- Adding new attributes to cartLines during MergeOperation?

grizzlypoppy
Shopify Partner
158 5 24

Hey guys, I have a quick question on this note in the changelog:

Screenshot 2024-07-03 at 7.36.06 AM.png


I can successfully pass in new attributes to the merged bundle, but how can I target individual components within the bundle for new line item attributes?

Say I want to add some new properties to one of the existing child components? Is it possible? cartLines seems to not accept attributes, as she just wants `id` and `quantity`

Is there any way to preserve existing line item attributes and also add some custom ones to children during the merge operation?

 

 

      operations.push({
        merge: {
          parentVariantId: parentLine.merchandise.id,
          cartLines: [
            {
              cartLineId: parentLine.id,
              quantity: parentLine.quantity,
            },
            ...relatedChildLines.map((childLine) => ({
              cartLineId: childLine.id,
              quantity: childLine.quantity,
            })),
          ],
          attributes: [{
            key: "newAttribute",
            value: "newValue!",
          }]
        }
      });

 

 

 

 

Screenshot 2024-07-03 at 7.29.22 AM.png

 

Replies 3 (3)

Liam
Community Manager
3108 344 899
Hi Grizzlypoppy,
 
I've connected with the product team on this, and they've advised that you can set attributes on ExpandedItem.
 
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

grizzlypoppy
Shopify Partner
158 5 24

Is this available on MergeOperation? Or do we have to use Expand?

grizzlypoppy
Shopify Partner
158 5 24

Thanks again @Liam for your response. Since this is a Merge Operation -- do you happen to know if `ExpandedItem` will still be accessible in the MergeOperation? 

Any insight here appreciated!! TIA