- 🇺🇸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.