Add address copying to the shipment add form

Created on 21 October 2022, over 2 years ago
Updated 25 January 2024, about 1 year ago

Right now, a typical checkout flow will have the customer provide a shipping address and then be able to copy that to the billing address. However, the flow in the order management interface for creating a new order involves inputting the billing address first. If you want to copy the shipping address to billing, you first have to create the order with no address, then add a shipment, then come back to the edit form to add a billing address.

We could simplify the order management flow by adding the ability to copy the billing address to the shipment on the shipment add form. Right now it does helpfully default to the customer's default address, but I don't see any reason it shouldn't support copying.

Feature request
Status

Active

Version

2.0

Component

User interface

Created by

🇺🇸United States rszrama

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States rhovland Oregon

    Definitely a sore point for us trying to move to creating manual orders in Drupal instead of our legacy order management system.
    Expect to see a patch for this soon. If you have any ideas on the best way to implement this please let me know.

    I was thinking instead of the usual interface for customer facing where it hides the form, it's instead a button that says "Copy billing address" and it populates the address form for the user so they know exactly what address is being used since it's not visible on that screen.

  • 🇺🇸United States rhovland Oregon

    So the first approach I took was trying to copy the billing profile into the shipment profile. That part works. If it's done during form build you get the address nicely displayed along with an edit button.

    But moving that to a button that invokes an ajax callback to copy the profile and refresh the form I ran into too many issues with the complex logic for building the form. Because the triggering element is not available at the right times during rebuilding the form I couldn't add the logic to render the profile on the form and was running afoul of the form validation for having empty address form fields. I attached a patch to with my work on this approach but it would require someone with deep knowledge of the shipment, profile, and address system to make it render the profile during refresh. And probably a lot of code changes and possibly even a rewrite of some parts based on my observations on code execution order in the debugger.

    The second approach which I'm working on right now is copying the profile values into the address form in a durable way. I've gotten most of the way there, just need to get the form to refresh correctly when the country is changed from the default.

  • 🇺🇸United States rhovland Oregon

    Here is an almost complete patch. I cannot figure out how to get the form to refresh via ajax here so some help is needed to get it working all the way.

  • 🇮🇳India drupalganesh

    I tried this patch, but not working for me. Not seeing "Copy billing address" button on the form.

  • 🇺🇦Ukraine marchuk.vitaliy Rivne, UA

    It seems we need to consider 2 cases:
    1. The customer (the owner of the order) has some profiles saved in the address book. In this case, after clicking "Copy billing address" we need to open the "+ Enter a new address" form and prefill the fields with the billing address.

    2. The customer (the owner of the order) doesn't have profiles saved in the address book. In this case, after clicking "Copy billing address" we need to prefill the fields with the billing address.

    Also, it looks like we need to add a "Copy billing address" button for the "Shipping information" widget only, as the integration will be different for each widget.

Production build 0.71.5 2024