Skip to content

Commit 96c4baf

Browse files
committed
MC-32655: (GraphQL) Set default value of save_in_address_book to true when no value is specified
- Fixed code as per new review comments
1 parent e804065 commit 96c4baf

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

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

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

60-
if ($addressInput) {
60+
if (!$customerAddressId && $addressInput) {
6161
$addressInput['save_in_address_book'] = isset($billingAddressInput['address']['save_in_address_book'])
6262
? (bool) $billingAddressInput['address']['save_in_address_book'] : true;
6363
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,11 @@ public function execute(ContextInterface $context, CartInterface $cart, array $s
4848
__('You cannot specify multiple shipping addresses.')
4949
);
5050
}
51-
$shippingAddressInput = current($shippingAddressesInput) ?? null;
51+
$shippingAddressInput = current($shippingAddressesInput) ?? [];
5252
$customerAddressId = $shippingAddressInput['customer_address_id'] ?? null;
5353

54-
if ($shippingAddressInput && !$customerAddressId) {
55-
$shippingAddressInput['address']['save_in_address_book'] = isset($shippingAddressInput['address']['save_in_address_book'])
56-
? (bool) $shippingAddressInput['address']['save_in_address_book'] : true;
54+
if (!$customerAddressId && !isset($shippingAddressInput['address']['save_in_address_book'])) {
55+
$shippingAddressInput['address']['save_in_address_book'] = true;
5756
}
5857

5958
$shippingAddress = $this->getShippingAddress->execute($context, $shippingAddressInput);

0 commit comments

Comments
 (0)