Skip to content

Commit 6cf0e98

Browse files
committed
setbilling address graphql save address in addressbook
1 parent a3c2af0 commit 6cf0e98

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
9090
);
9191
}
9292

93-
$billingAddress = $this->createBillingAddress($context, $customerAddressId, $addressInput);
93+
$billingAddress = $this->createBillingAddress($context, $customerAddressId, $addressInput,$sameAsShipping);
9494

9595
$this->assignBillingAddressToCart->execute($cart, $billingAddress, $sameAsShipping);
9696
}
@@ -109,16 +109,17 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
109109
private function createBillingAddress(
110110
ContextInterface $context,
111111
?int $customerAddressId,
112-
?array $addressInput
112+
?array $addressInput,
113+
$sameAsShipping
113114
): Address {
114115
if (null === $customerAddressId) {
115116
$billingAddress = $this->quoteAddressFactory->createBasedOnInputData($addressInput);
116117

117118
$customerId = $context->getUserId();
118119
// need to save address only for registered user and if save_in_address_book = true
119-
if (0 !== $customerId
120+
if ((0 !== $customerId
120121
&& isset($addressInput['save_in_address_book'])
121-
&& (bool)$addressInput['save_in_address_book'] === true
122+
&& (bool)$addressInput['save_in_address_book'] && $sameAsShipping !== true) === true
122123
) {
123124
$this->saveQuoteAddressToCustomerAddressBook->execute($billingAddress, $customerId);
124125
}

0 commit comments

Comments
 (0)