@@ -59,6 +59,24 @@ public function __construct(
59
59
$ this ->customerFactory = $ customerFactory ;
60
60
}
61
61
62
+ /**
63
+ * Curate shipping and billing default options
64
+ *
65
+ * @param array $address
66
+ * @param AddressInterface $addressObject
67
+ * @return null
68
+ */
69
+ private function curateAddressDefaultValues (array $ address , AddressInterface $ addressObject ) : array
70
+ {
71
+ $ customerModel = $ this ->customerFactory ->create ();
72
+ $ this ->customerResourceModel ->load ($ customerModel , $ addressObject ->getCustomerId ());
73
+ $ address [CustomerInterface::DEFAULT_BILLING ] =
74
+ ($ addressObject ->getId () == $ customerModel ->getDefaultBillingAddress ()->getId ()) ? true : false ;
75
+ $ address [CustomerInterface::DEFAULT_SHIPPING ] =
76
+ ($ addressObject ->getId () == $ customerModel ->getDefaultShippingAddress ()->getId ()) ? true : false ;
77
+ return $ address ;
78
+ }
79
+
62
80
/**
63
81
* Transform single customer address data from object to in array format
64
82
*
@@ -72,12 +90,7 @@ public function processCustomerAddress(AddressInterface $addressObject) : array
72
90
AddressRepositoryInterface::class,
73
91
'getById '
74
92
);
75
- $ customerModel = $ this ->customerFactory ->create ();
76
- $ this ->customerResourceModel ->load ($ customerModel , $ addressObject ->getCustomerId ());
77
- $ address [CustomerInterface::DEFAULT_BILLING ] =
78
- ($ addressObject ->getId () == $ customerModel ->getDefaultBillingAddress ()->getId ()) ? true : false ;
79
- $ address [CustomerInterface::DEFAULT_SHIPPING ] =
80
- ($ addressObject ->getId () == $ customerModel ->getDefaultShippingAddress ()->getId ()) ? true : false ;
93
+ $ address = $ this ->curateAddressDefaultValues ($ address , $ addressObject );
81
94
82
95
if (isset ($ address [CustomAttributesDataInterface::EXTENSION_ATTRIBUTES_KEY ])) {
83
96
$ address = array_merge ($ address , $ address [CustomAttributesDataInterface::EXTENSION_ATTRIBUTES_KEY ]);
0 commit comments