Skip to content

Commit 756aedf

Browse files
author
Prabhu Ram
committed
Merge branch 'patch-1' of https://github.com/Aniket10Nov/magento2 into 2.4-develop
2 parents 047f5b9 + e5cf14c commit 756aedf

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 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
}
@@ -101,6 +101,7 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
101101
* @param ContextInterface $context
102102
* @param int|null $customerAddressId
103103
* @param array $addressInput
104+
* @param bool $sameAsShipping
104105
* @return Address
105106
* @throws GraphQlAuthorizationException
106107
* @throws GraphQlInputException
@@ -109,16 +110,17 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
109110
private function createBillingAddress(
110111
ContextInterface $context,
111112
?int $customerAddressId,
112-
?array $addressInput
113+
?array $addressInput,
114+
$sameAsShipping
113115
): Address {
114116
if (null === $customerAddressId) {
115117
$billingAddress = $this->quoteAddressFactory->createBasedOnInputData($addressInput);
116118

117119
$customerId = $context->getUserId();
118120
// need to save address only for registered user and if save_in_address_book = true
119-
if (0 !== $customerId
121+
if ((0 !== $customerId
120122
&& isset($addressInput['save_in_address_book'])
121-
&& (bool)$addressInput['save_in_address_book'] === true
123+
&& (bool)$addressInput['save_in_address_book'] && $sameAsShipping !== true) === true
122124
) {
123125
$this->saveQuoteAddressToCustomerAddressBook->execute($billingAddress, $customerId);
124126
}

0 commit comments

Comments
 (0)