Skip to content

Commit 88b2b44

Browse files
committed
MC-32655: (GraphQL) Set default value of save_in_address_book to true when no value is specified
- Added code fix
1 parent f55ee68 commit 88b2b44

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
namespace Magento\QuoteGraphQl\Model\Cart;
99

1010
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
11-
use Magento\GraphQl\Model\Query\ContextInterface;
1211
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1312
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
13+
use Magento\GraphQl\Model\Query\ContextInterface;
1414
use Magento\Quote\Model\Quote\Address;
1515

1616
/**
@@ -49,6 +49,8 @@ public function execute(ContextInterface $context, array $shippingAddressInput):
4949

5050
if ($addressInput) {
5151
$addressInput['customer_notes'] = $shippingAddressInput['customer_notes'] ?? '';
52+
$addressInput['save_in_address_book'] = isset($shippingAddressInput['address']['save_in_address_book'])
53+
? (bool) $shippingAddressInput['address']['save_in_address_book'] : true;
5254
}
5355

5456
if (null === $customerAddressId && null === $addressInput) {
@@ -63,6 +65,7 @@ public function execute(ContextInterface $context, array $shippingAddressInput):
6365
);
6466
}
6567

68+
6669
$shippingAddress = $this->createShippingAddress($context, $customerAddressId, $addressInput);
6770

6871
return $shippingAddress;

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
5656
{
5757
$customerAddressId = $billingAddressInput['customer_address_id'] ?? null;
5858
$addressInput = $billingAddressInput['address'] ?? null;
59+
60+
if ($addressInput) {
61+
$addressInput['save_in_address_book'] = isset($billingAddressInput['address']['save_in_address_book'])
62+
? (bool) $billingAddressInput['address']['save_in_address_book'] : true;
63+
}
64+
5965
// Need to keep this for BC of `use_for_shipping` field
6066
$sameAsShipping = isset($billingAddressInput['use_for_shipping'])
6167
? (bool)$billingAddressInput['use_for_shipping'] : false;

0 commit comments

Comments
 (0)