Skip to content

Commit

Permalink
Merge branch 'patch-1' of https://github.com/Aniket10Nov/magento2 int…
Browse files Browse the repository at this point in the history
…o 2.4-develop
  • Loading branch information
prabhuram93 committed Mar 17, 2020
2 parents 047f5b9 + e5cf14c commit 756aedf
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
);
}

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

$this->assignBillingAddressToCart->execute($cart, $billingAddress, $sameAsShipping);
}
Expand All @@ -101,6 +101,7 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
* @param ContextInterface $context
* @param int|null $customerAddressId
* @param array $addressInput
* @param bool $sameAsShipping
* @return Address
* @throws GraphQlAuthorizationException
* @throws GraphQlInputException
Expand All @@ -109,16 +110,17 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
private function createBillingAddress(
ContextInterface $context,
?int $customerAddressId,
?array $addressInput
?array $addressInput,
$sameAsShipping
): Address {
if (null === $customerAddressId) {
$billingAddress = $this->quoteAddressFactory->createBasedOnInputData($addressInput);

$customerId = $context->getUserId();
// need to save address only for registered user and if save_in_address_book = true
if (0 !== $customerId
if ((0 !== $customerId
&& isset($addressInput['save_in_address_book'])
&& (bool)$addressInput['save_in_address_book'] === true
&& (bool)$addressInput['save_in_address_book'] && $sameAsShipping !== true) === true
) {
$this->saveQuoteAddressToCustomerAddressBook->execute($billingAddress, $customerId);
}
Expand Down

0 comments on commit 756aedf

Please sign in to comment.