Storefront API bug when changing line item variant

The issue happens with BXGY in any cart drawer that allows to change line item variants.

This is the storefront api mutation to update the line item variant:

mutation {
   cartLinesUpdate(cartId: $cartId, lines: $linesToUpdate) {
      cart {
        ...cartFields
      }
      userErrors {
        code
        field
        message
      }
      warnings {
        code
        message
        target
      }
    }
}

With linesToUpdate looking like this:

{
          id: lineToChangeId,
          merchandiseId: newSelectedVariantId,
 }

You can see an example cart, where if we change the variant of the either line, the other will change as well to the same new variant and they will always be synced.

I would expect only one of them to change, since they have different line item ids, but the storefront api seems to consider them as the same, without accounting for the BXGY discount applied.

Is this expected? We’ve had stores complain about and can reproduce it consistently.

Hey @Zak :waving_hand: - thanks for reporting this! Just to make sure I understand the issue correctly:

When you use cartLinesUpdate to change the variant of one line item (using its specific line ID), are you seeing both line items update to that same new variant?

From your screenshot, I can see you have:

  • Line 1: Regular priced item (€79.95)

  • Line 2: Same item but FREE (BXGY promotion)

So if you try to change just the paid item from “Donker Blauw” to, say, a variant called “Red” - are both lines switching to “Red” even though you only specified one line ID in the mutation?

My thinking is that this might be unexpected behaviour since they have different line IDs. I don’t believe the BXGY relationship shouldn’t force them to stay synchronized like that.

Would you be able to share which variant are you trying to change to and if you’re only passing one line ID in linesToUpdate, or both? I can see if I’m able to replicate your set up on my end here and troubleshoot a bit with you.

Happy to help dig into this further!

Hey @Alan_G! You got it right, I only switch the paid one to “Red” passing only its line id in the mutation variables but then both update, which is not what I would expect.

It seems like the storefront Api is not aware that the BXGY discount has split them and still sees them as one line.

I have tested it on all the latest 3 API versions, they all still have this bug.
It would be amazing if this could be fixed, as it has been affecting multiple merchants.

Please let me know if there are any details you might need in order to reproduce this. But it’s a very simple issue to reproduce, which makes me think it might have been introduced recently somehow, because we have only noticed it yesterday after months.

Thanks for clarifying @Zak, this does sound like possibly unexpected behaviour.

Would you be able to share quick screen recording of it happening, an X-Request-ID from one of the affected mutations (should be able to pull that from the response headers in your API call) and your shop ID (happy to take this via DM if you prefer!). No worries if you can only share a few of those things, just want to make sure we’re able to check the logs on our end and so that I can reproduce your exact setup so we can dig into this further - speak soon!

Thank you for looking into this @Alan_G!

Shop id: gid://shopify/Shop/72847524097
X-Request-ID: fd0e2c81-27ae-4e5a-87bc-133429d5d1fb-1749083785

Thanks @Zak for sharing that request ID- I’ll do some digging into this for you and loop back in the thread here once I have a solution/next steps to share.