@@ -90,7 +90,7 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
90
90
);
91
91
}
92
92
93
- $ billingAddress = $ this ->createBillingAddress ($ context , $ customerAddressId , $ addressInput );
93
+ $ billingAddress = $ this ->createBillingAddress ($ context , $ customerAddressId , $ addressInput, $ sameAsShipping );
94
94
95
95
$ this ->assignBillingAddressToCart ->execute ($ cart , $ billingAddress , $ sameAsShipping );
96
96
}
@@ -101,6 +101,7 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
101
101
* @param ContextInterface $context
102
102
* @param int|null $customerAddressId
103
103
* @param array $addressInput
104
+ * @param bool $sameAsShipping
104
105
* @return Address
105
106
* @throws GraphQlAuthorizationException
106
107
* @throws GraphQlInputException
@@ -109,16 +110,17 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
109
110
private function createBillingAddress (
110
111
ContextInterface $ context ,
111
112
?int $ customerAddressId ,
112
- ?array $ addressInput
113
+ ?array $ addressInput ,
114
+ $ sameAsShipping
113
115
): Address {
114
116
if (null === $ customerAddressId ) {
115
117
$ billingAddress = $ this ->quoteAddressFactory ->createBasedOnInputData ($ addressInput );
116
118
117
119
$ customerId = $ context ->getUserId ();
118
120
// need to save address only for registered user and if save_in_address_book = true
119
- if (0 !== $ customerId
121
+ if (( 0 !== $ customerId
120
122
&& isset ($ addressInput ['save_in_address_book ' ])
121
- && (bool )$ addressInput ['save_in_address_book ' ] === true
123
+ && (bool )$ addressInput ['save_in_address_book ' ] && $ sameAsShipping !== true ) === true
122
124
) {
123
125
$ this ->saveQuoteAddressToCustomerAddressBook ->execute ($ billingAddress , $ customerId );
124
126
}
0 commit comments