Skip to content

Commit bd4a599

Browse files
committed
MC-32655: (GraphQL) Set default value of save_in_address_book to true when no value is specified
- Refactored logic on resolver
1 parent 3ff1ad9 commit bd4a599

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
5757
$customerAddressId = $billingAddressInput['customer_address_id'] ?? null;
5858
$addressInput = $billingAddressInput['address'] ?? null;
5959

60-
if (!$customerAddressId && $addressInput) {
61-
$addressInput['save_in_address_book'] = isset($billingAddressInput['address']['save_in_address_book'])
62-
? (bool) $billingAddressInput['address']['save_in_address_book'] : true;
60+
if (!$customerAddressId && !isset($billingAddressInput['address']['save_in_address_book']) && $addressInput) {
61+
$addressInput['save_in_address_book'] = true;
6362
}
6463

6564
// Need to keep this for BC of `use_for_shipping` field
@@ -68,6 +67,7 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
6867
$sameAsShipping = isset($billingAddressInput['same_as_shipping'])
6968
? (bool)$billingAddressInput['same_as_shipping'] : $sameAsShipping;
7069

70+
7171
if (null === $customerAddressId && null === $addressInput) {
7272
throw new GraphQlInputException(
7373
__('The billing address must contain either "customer_address_id" or "address".')

0 commit comments

Comments
 (0)