(REGRESSION) useApplyShippingAddressChange hook on one-page checkout changes back to the first saved address

This seems to be a regression of the same issue I previously reported here:

Now the merchant has reached out again saying that a customer has reported a similar issue. The app is automatically updating the zip code with the +4 code using this hook, so when the customer selects a different saved address other than the first one, it updates and then reselects the first address again. I’m also seeing a loop where you can’t even open the saved addresses list because the address changes and then it closes it automatically.

Can you please look into this ASAP? Last time it took 3 months to fix :frowning:

Let me know if you need any more information.

Hi David,

Thanks for reporting this here - I’ve connected with the product team who own this area to investigate this. However there may not be an update on this until next week as the product team are currently out of office.

1 Like

Thanks for the update

Hi David,

We weren’t able to reproduce the issue on our end. Would you be able to provide some extension code that illustrates the problem (including the extension target you are using)? Can you also confirm whether this is happening on customer account checkouts or shop pay?

Thanks for investigating. I’m actually having some trouble reproducing this as well now. I guess it might not be the same issue as before, but from the video the merchant shared from the customer it looks identical (clicking any address or adding a new address is causing the first address to be selected). I can’t reproduce this exact behaviour however.

I was seeing a different issue on the merchant’s website that wasn’t showing in development, where selecting the “Use a saved address” button would briefly flash the address selector, and then the address would update and it would disappear again, making it impossible to select an address. I deleted the one address it kept defaulting to on my account on the site, and it stopped doing that, which makes me wonder if it’s something only with certain address configurations.

I’ve contacted the merchant for more information to try to debug this further, and also linked them to this discussion.

Also, I don’t know whether it works on Shop Pay or not, since I can’t figure out how to set up a test system, but that’s not where the issue was appearing originally. It does in fact occur due to the customer being logged into an account at checkout.

And finally, the extension target should be purchase.checkout.delivery-address.render-before. Unfortunately, I am currently not able to create a reproducible example.

So the issue I’m seeing and reproducing is when you click on “Use a saved address”, if the first address in the list doesn’t have the full zip code, the app updates the address to include the full zip code. And when this happens, the saved address list is hidden because the address has changed to one that isn’t in the list.

@James_Vidler I’ve been told the issue is occurring on Shop Pay express checkout as well.

But I think the problem could be solved if the first address wasn’t selected automatically after clicking “Use a saved address”. It should be left empty for the user to select an address instead, unless the current address already exists in the list where it should select that one instead. Then, when the customer selects an address, it would be a user interaction causing the address change and so automatically updating the address would be okay. Otherwise, what’s happening is clicking “Use a saved address” opens the saved addresses, automatically selects the first one, which changes the address, and then the app updates the zip code, which closes the saved addresses. This all happens very quickly and prevents selecting any different address.

You should be able to reproduce this by creating an extension that changes any part of the address to something else whenever the address changes (override the zip code, for example, and then having a customer account with multiple addresses. Enter a different address, then click “Use a saved address”. It should select the first address automatically, and your extension should update the address. Also remember it only happens on one page checkout.

Hi, I was able to reproduce the following issue in a simple test project.

When the list of addresses is opened, the app automatically updates the values, causing the input form to appear and preventing the buyer from selecting a different address.

You can see the issue here:
https://jam.dev/c/c49b71db-7091-4ad4-859a-d8fdb40dfc21

The code used for testing is available here. It’s simply a scaffolded app that calls useApplyShippingAddressChange :