Disable profile copy checkbox on admin order edit page

Created on 19 July 2024, about 2 months ago
Updated 22 July 2024, about 2 months ago

This is a tricky issue, because I'm not sure the actual desired outcome. Profile copying on the backend currently supports copying the shipping address to the billing information on the order edit page, but you would almost never create a shipment prior to inputting a billing address were you actually to create an order from scratch.

Additionally, since the checkbox is present and checked by default when editing an order after a shipment has been created, either through the normal checkout flow or through clever use of the order admin UI, you then run the risk of accidentally changing the billing address if you were to edit a shipment's address and then come update some other part of the order, saving it without unchecking that checkbox.

Given the way order editing and shipment management currently works, I think our best option would be for the order edit interface to simply not support profile copying. We already don't support it on the shipment add / edit form, which would be the more natural place to have profile copying anyways, and by using the checkbox on the order edit form, we actually obscure the currently entered address when you open the edit form:

I think it would be better to just not use that checkbox on the order edit form and default to the addressbook widget:

I'm going to open a separate issue in Commerce Shipping to embed the order shipping address in the right column. That way we can at least see what the current shipping address is and even manually copy it if so desired.

📌 Task
Status

Active

Version

2.0

Component

Code

Created by

🇺🇸United States rszrama

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @rszrama
  • 🇮🇱Israel jsacksick

    Actually, disabling the profile copying would have to be done from Commerce shipping itself, since it is the one adding that checkbox, via the following code:

    /**
     * Implements hook_commerce_inline_form_PLUGIN_ID_alter().
     */
    function commerce_shipping_commerce_inline_form_customer_profile_alter(array &$inline_form, FormStateInterface $form_state, array &$complete_form) {
      // Attach the "Billing same as shipping" element.
      $profile_field_copy = \Drupal::service('commerce_shipping.profile_field_copy');
      if ($profile_field_copy->supportsForm($inline_form, $form_state)) {
        $profile_field_copy->alterForm($inline_form, $form_state);
      }
    }

    We'd probably need to alter the supportsForm() method to check if the form is the order edit form.

  • 🇺🇸United States rszrama

    Ahh, thanks! I didn't look too deeply into where the checkbox came from. I'm going to relate this one to another shipping UX improvement I proposed for the order edit form, too.

Production build 0.71.5 2024