commerce icon indicating copy to clipboard operation
commerce copied to clipboard

[3.x]: Can't edit billing address in CP when both shipping and billing addresses have the same ID

Open modelesque opened this issue 2 years ago • 1 comments

What happened?

Description

My team have been reporting for months that they (sometimes) can't edit an order's billing address in the CP. I have finally gotten around to looking into it, believing that it could be related to some of my custom module code that extends Craft/Commerce. I haven't found anywhere where my code could be interfering.

After taking a deep dive examining all the orders my team reported whose billing address was editable and those whose were not, I discovered a correlation: when the billing and shipping addresses have the same id (meaning they are the same exact Address model), then changes made to billing do not get saved. If they have different IDs, then the changes get saved.

Also worth pointing out: if the addresses have the same IDs, then I'm able to edit the shipping address with no problems, and any changes I make also get reflected on the billing address. It's only when I try to edit the billing address.

Steps to reproduce

  1. Create an order.
  2. Add identical billing and shipping addresses, where each Address model has the same id.
  3. Edit the billing address in the CP, save your changes.
  4. The CP will show a success flash message but your changes will not be shown in the address.
  5. Try editing the shipping address. If it's like my environment, the changes will be reflected in both the billing and shipping address, as expected (since they are both the same Address model).

Expected behavior

I expect to be able to edit the billing or shipping address freely and my changes get saved. If they are the same Address model, I expect editing one doesn't affect the other.

Actual behavior

Editing the billing address in the CP doesn't save my changes when it's the same Address model as shipping. However, conversely, I can edit the shipping address and see its changes getting applied to billing with no problems.


If this turns out to be expected behavior, I would like to know why and what I can do to let my team freely edit either address. If it turns out to be a bug you can't reproduce, I would gladly jump in a video call and share my screen to demonstrate it and try to hunt down the bug.

Craft CMS version

Craft Pro 3.7.63.1

Craft Commerce version

3.4.19

PHP version

8.0.25

Operating system and version

Linux 5.10.0-0.deb10.17-amd64

Database type and version

MySQL 10.6.8

Image driver and version

No response

Installed plugins and versions

modelesque avatar Mar 16 '23 17:03 modelesque

@modelesque This is a bug on Commerce v3. IDs for billing and shipping addresses should always be different when selecting them. The workaround, for now, is to click on copy to shipping or billing address setting option when clicking the cog icon.

pdaleramirez avatar Mar 22 '23 06:03 pdaleramirez