Cart transform expand operation does not persist attributes

Solved

Cart transform expand operation does not persist attributes

delyanpeev
Shopify Partner
8 1 6

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 3 (3)

delyanpeev
Shopify Partner
8 1 6

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

Alacart-Apps
Shopify Partner
1 0 6

Attributes are considered an unbounded list, so they behave in a specific way inside of a cart transform function.

 

The example Github repo for "Warranty add-on" sets a cart line attribute/property (Warranty: yes). If the same product also had a personalization field on the product details page setting a different attribute/property like "Personalization" - this field is completely missing from the Order once it is placed. 

 

It is impossible for one cart function to know all the properties/attributes added by other apps, storefront customizations, etc - this means there will always be data loss due to the cart transform function limitations. Shopify orders will not be accurate in this case!

 

All attributes on the primary product should simply pass-thru to the expanded primary product. This seems like a huge compatibility concern causing more support for merchants to seek out.

 

Even in the most basic use case, an expanded item, loses all attributes once the order is placed. Even if a cart function does't specify or use the attributes. 

 

@Nick_Wesselman is this the expected behaviour or is this a bug in expand operations?