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.

Hey @Alan_G, just checking in, any news on this?

Hey @Zak :waving_hand: - thanks for following up and apologies for the delay in my response here. We did recently push a fix for a similar issue recently, are you still seeing the variants are both changing to the same one? I tried to replicate this using the below mutation and it does seem to update the variants correctly (I’m using a cart drawer in the Dawn theme):

mutation updateLine($cartId: ID!, $lines: [CartLineUpdateInput!]!) {
  cartLinesUpdate(cartId: $cartId, lines: $lines) {
    cart {
      lines(first: 10) {
        edges {
          node {
            id
            merchandise {
              ... on ProductVariant {
                id
                title
              }
            }
            cost {
              totalAmount {
                amount
              }
            }
          }
        }
      }
    }
  }
}

Input Variables:

{
  "cartId": "gid://shopify/Cart/Z2NwLXVzLWNlbnRyYWwxOjAxSloxM0g2N1NLVFdFUDc4WTM2U0JaRVFK?key=d7dee8e9434ead84bf2290cb526506d5",
  "lines": [{
    "id": "gid://shopify/CartLine/10e879fb-96f8-4e1f-85c2-3dd1edd37d14?cart=Z2NwLXVzLWNlbnRyYWwxOjAxSloxM0g2N1NLVFdFUDc4WTM2U0JaRVFK",
    "merchandiseId": "gid://shopify/ProductVariant/52119751753750"
  }]}

Can you let me know if you’re still seeing the issue pop up? If so, if you’re able to share a new example I’m more than happy to take a look (if you’re able to share a screen recording through Loom, for example that would be really helpful as well)

Hope this helps, let me know if I can clarify anything as always!

@Alan_G Was your test conducted on one line item with quantity 2 that was then split into two lines, both the same variant since they come from the same initial line, but one full price and the other discounted at 100% due to a BXGY discount?

If not, then it’s expected to work normally, the issue only happens when there are two lines that were originally the same line, but due to a BXGY discount they were split into two lines. It seems like not all the storefront API’s moving parts are aware of the line being split into two separate ones.

are you still seeing the variants are both changing to the same one

I still see the same issue happen and it’s slightly worse than before, because now when I change the BX line’s variant, the variant will not be changed and it will retain whatever variant the GY line has, like if the GY line’s variant is the source of truth.
If instead I change the GY line’s variant, then the previous unexpected behaviour still happens and both BX and GY lines are changed to the same variant that was selected only for the GY line.

Hey @Zak - thanks for clarifying, I believe I was able to replicate this on my end now. I’m looking into this and I’ll loop back with you once I have some more info!

Hey @Zak - just following up here. I was able to investigate this with our cart developers and it does look like this is a potential bug. We’re still investigating this, but just wanted to provide an update here. Thanks again for your patience on this!

Hey @Alan_G, thanks for the follow up!

There’s a very similar bug that affects BXGY discounts when upgrading one or multiple lines of a BXGY discount to a selling plan.

To reproduce it’s similar to the previous bug that happened when changing the cart line variant, but this time instead of changing the line variant we add a selling plan.
You’ll see that the BXGY discount disappears and only the subscription discount is applied.

This does not happen if, for example, the two lines of a BXGY are different variants or have different line properties, just like with the initial bug mentioned in this forum post.

Do you have any ETA for when this will be fixed?

Hey @Zak - no worries, thank you for following up too. That does sound pretty similar to the issue we’re investigating here. Would you be open to sharing a video (through Loom or another video sharing service), just so that we’re able to take a look at the exact replication steps? I can link back up with our product team on this for you to investigate further.

For the initial issue, I still don’t have a concrete update, but once I hear back from you here, I can share that new information with the product team and see if we can expedite a fix. I still can’t guarantee a specific turnaround time, but happy to advocate further for you since I know it’s taken a little while to get this resolved. Hope to speak soon!

Hey @Alan_G, thanks for the reply. Could you please PM me so that I can share the loom with relevant details?

Hey @Zak - no worries. I’ll send you that DM right away here. :slight_smile:

Hi we are facing quite a similar Issue. But this is related to the subscription and quantity changes. The Upsell in the cart edits the quantities and it seems the bundle and Subscription logik is not properly working:

Hi @Lorenz :waving_hand:, thanks for reporting this as well, this does seem like similar behaviour to what Zak had reported earlier. Would you be able to share an x-request-id for one of these cart requests where the subscription quantities seem to be incorrect from the Google Chrome Dev Tools network tab, like this?


This ID would likely be under the “response” headers section for a “change” action.

I can share those examples with our developers as well so we can continue to investigate this. As a general update, I did just want to share that we are still investigating this and I can’t share too many details, but I will do my best to prioritize a resolution as soon as we can here. Having more examples of the issue does generally help us get things looked at faster. Hope to hear from you soon!