Skip to content

Commit 0a3224f

Browse files
committed
MC-32655: (GraphQL) Set default value of save_in_address_book to true when no value is specified
- Static failure fixes
1 parent 9a92035 commit 0a3224f

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

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

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,29 +67,43 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
6767
$sameAsShipping = isset($billingAddressInput['same_as_shipping'])
6868
? (bool)$billingAddressInput['same_as_shipping'] : $sameAsShipping;
6969

70+
$this->checkForInputExceptions($customerAddressId, $addressInput);
7071

71-
if (null === $customerAddressId && null === $addressInput) {
72+
$addresses = $cart->getAllShippingAddresses();
73+
if ($sameAsShipping && count($addresses) > 1) {
7274
throw new GraphQlInputException(
73-
__('The billing address must contain either "customer_address_id" or "address".')
75+
__('Using the "same_as_shipping" option with multishipping is not possible.')
7476
);
7577
}
7678

77-
if ($customerAddressId && $addressInput) {
79+
$billingAddress = $this->createBillingAddress($context, $customerAddressId, $addressInput);
80+
81+
$this->assignBillingAddressToCart->execute($cart, $billingAddress, $sameAsShipping);
82+
}
83+
84+
85+
/**
86+
* Check for the input exceptions
87+
*
88+
* @param int|null $customerAddressId
89+
* @param array|null $addressInput
90+
* @throws GraphQlInputException
91+
*/
92+
private function checkForInputExceptions(
93+
?int $customerAddressId,
94+
?array $addressInput
95+
) {
96+
if (null === $customerAddressId && null === $addressInput) {
7897
throw new GraphQlInputException(
79-
__('The billing address cannot contain "customer_address_id" and "address" at the same time.')
98+
__('The billing address must contain either "customer_address_id" or "address".')
8099
);
81100
}
82101

83-
$addresses = $cart->getAllShippingAddresses();
84-
if ($sameAsShipping && count($addresses) > 1) {
102+
if ($customerAddressId && $addressInput) {
85103
throw new GraphQlInputException(
86-
__('Using the "same_as_shipping" option with multishipping is not possible.')
104+
__('The billing address cannot contain "customer_address_id" and "address" at the same time.')
87105
);
88106
}
89-
90-
$billingAddress = $this->createBillingAddress($context, $customerAddressId, $addressInput);
91-
92-
$this->assignBillingAddressToCart->execute($cart, $billingAddress, $sameAsShipping);
93107
}
94108

95109
/**

0 commit comments

Comments
 (0)