Solved

Cart transform expand operation does not persist attributes

delyanpeev
Shopify Partner
7 1 4

Hello there,

 

I've been observing something that seems strange to me.

 

Adding two items in cart that have some attribute(s), say

 

KeyA: ValueA

 

And having them expanded by a function with an output similar to this:

 

{
  "operations": [
    {
      "expand": {
"title": "Hello", "cartLineId": "gid://shopify/CartLine/someId1", "expandedCartItems": [ { "merchandiseId": "gid://shopify/ProductVariant/42836213563550", "quantity": 1 } ] } },
{
"expand": {
"title": "Goodbye",
"cartLineId": "gid://shopify/CartLine/someId2",
"expandedCartItems": [
{
"merchandiseId": "gid://shopify/ProductVariant/42836213563550",
"quantity": 1
}
]
}
} ] }

 Everything looks good within the checkout page, but the attributes these cart line items had are not available within the order (neither in the UI, nor returned from the GraphQL Admin API).

 

Doing the same thing with identical properties, but using a merge function to merge multiple cart line items into one actually persists each cart line item's properties and they are displayed on the order page.

 

This seems a bit strange as if one of the operations should remove attributes, I would expect the exact opposite to happen - the merge to remove attributes as it is merging multiple cart line items into one and potential duplicates can cause collisions.

 

Am I missing something as the expand functionality was suggested for usage to me by Shopify support, however it erasing attributes is a dealbreaker for our usecase?

 

Thanks

Accepted Solution (1)
MathewKostiuk
Shopify Partner
1 1 0

This is an accepted solution.

This might be fixed in the latest version (2024-04): https://shopify.dev/docs/api/functions/reference/cart-transform/graphql/common-objects/expandeditem?...

 

There's a new 'attributes' property that I believe you can use to add to each item

View solution in original post

Replies 2 (2)

delyanpeev
Shopify Partner
7 1 4

Here's the difference between two identical cart line items in two orders - first one merged 2 identical items and the next one expanded 2 identical items.

delyanpeev_0-1711367640340.png

The attributes are visible and the "Part of: ..." text shows the cart transform has been used.

 

And here's the next one, showing the expand being used and the attributes missing:

delyanpeev_1-1711367727548.png

 

MathewKostiuk
Shopify Partner
1 1 0

This is an accepted solution.

This might be fixed in the latest version (2024-04): https://shopify.dev/docs/api/functions/reference/cart-transform/graphql/common-objects/expandeditem?...

 

There's a new 'attributes' property that I believe you can use to add to each item