@@ -38,27 +38,16 @@ public function execute(
3838
3939 $ quote = $ this ->quoteRepository ->get ($ order ->getQuoteId ());
4040
41- foreach ($ this ->helper ->getExtraCheckoutAddressFields ('extra_checkout_billing_address_fields ' ) as $ extraField ) {
42- $ set = 'set ' . str_replace (' ' , '' , ucwords (str_replace ('_ ' , ' ' , $ extraField )));
43- $ get = 'get ' . str_replace (' ' , '' , ucwords (str_replace ('_ ' , ' ' , $ extraField )));
44-
45- try {
46- $ order ->getBillingAddress ()->$ set ($ quote ->getBillingAddress ()->$ get ())->save ();
47- } catch (\Exception $ e ) {
48- $ this ->logger ->critical ($ e ->getMessage ());
49- }
50- }
51-
52- foreach ($ this ->helper ->getExtraCheckoutAddressFields ('extra_checkout_shipping_address_fields ' ) as $ extraField ) {
53- $ set = 'set ' . str_replace (' ' , '' , ucwords (str_replace ('_ ' , ' ' , $ extraField )));
54- $ get = 'get ' . str_replace (' ' , '' , ucwords (str_replace ('_ ' , ' ' , $ extraField )));
55-
56- try {
57- $ order ->getShippingAddress ()->$ set ($ quote ->getShippingAddress ()->$ get ())->save ();
58- } catch (\Exception $ e ) {
59- $ this ->logger ->critical ($ e ->getMessage ());
60- }
61- }
62-
41+ $ this ->helper ->transportFieldsFromExtensionAttributesToObject (
42+ $ quote ->getBillingAddress (),
43+ $ order ->getBillingAddress (),
44+ 'extra_checkout_billing_address_fields '
45+ );
46+
47+ $ this ->helper ->transportFieldsFromExtensionAttributesToObject (
48+ $ quote ->getShippingAddress (),
49+ $ order ->getShippingAddress (),
50+ 'extra_checkout_shipping_address_fields '
51+ );
6352 }
6453}
0 commit comments