There are three cases in which a customer profile is not new:
1) The administrator is editing the order.
2) The customer is editing their payment method.
3) The customer has come back from the Review page to re-edit their address.

In all three cases, we add a special "_original" option to the select_address dropdown:

    // The customer profile is not new, indicating that it is being edited.
    // Add an _original option to allow the customer to revert their changes
    // after selecting a different option.
    if (!$this->entity->isNew()) {
      $profile_options['_original'] = $this->entity->label();

The customer profile also has a matching address book profile, which is also shown in the select_address dropdown.
If the two profiles are identical, we remove the _original option, because there is no point in having two options with the same labels and data.

Now, the trouble starts if we have two identical labels (same address_line1) but the profiles are not identical. We add "(original version)"
to _original and "(updated version)" to the source profile, under the assumption that the mismatch is because the customer edited their address book profile after the order was placed. However, that assumption only covers #1 and #2, it doesn't make sense for #3, where the "Updated version" is actually the older version.

Now, we already have an issue (#3067030: Expand the default profile label (currently: address_line1)) for expanding the label, which would reduce the frequency of this case. But we still need to adjust the logic. I suggest no longer guessing which version is the newer one, and only adding a suffix to _original. I also suggest making the _original suffix be "(current version)", that is the only option I could think of which satisfies all three cases.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bojanz created an issue. See original summary.

bojanz’s picture

Title: Improve the CustomerProfile::buildOptions() logic for non-new profiles » Improve the address book (CustomerProfile widget) label suffix for non-new profiles
Status: Active » Needs review
FileSize
2.83 KB

Better title. And a patch.

  • bojanz committed a570b3a on 8.x-2.x
    Issue #3116520 by bojanz: Improve the address book (CustomerProfile...
bojanz’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.