Skip to content

Commit 0fbc61c

Browse files
ENGCOM-4807: [WIP] Remove “cart_address_id” from “ShippingMethodInput” #609
- Merge Pull Request magento/graphql-ce#609 from magento/graphql-ce:Remove_cart_address_id_from_ShippingMethodInput - Merged commits: 1. 3c3d7ff 2. 6ab1392 3. 0ef9ba0 4. 3006409 5. c7da38b 6. fa8fc34 7. 2bd1c30 8. 817e766
2 parents 45a6365 + 817e766 commit 0fbc61c

11 files changed

+31
-339
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public function execute(QuoteAddress $address): array
5050
}
5151

5252
$addressData = array_merge($addressData, [
53-
'address_id' => $address->getId(),
5453
'address_type' => $addressType,
5554
'country' => [
5655
'code' => $address->getCountryId(),

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

Lines changed: 0 additions & 83 deletions
This file was deleted.

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

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,17 @@
1616
*/
1717
class SetShippingMethodsOnCart implements SetShippingMethodsOnCartInterface
1818
{
19-
/**
20-
* @var GetQuoteAddress
21-
*/
22-
private $getQuoteAddress;
23-
2419
/**
2520
* @var AssignShippingMethodToCart
2621
*/
2722
private $assignShippingMethodToCart;
2823

2924
/**
30-
* @param GetQuoteAddress $getQuoteAddress
3125
* @param AssignShippingMethodToCart $assignShippingMethodToCart
3226
*/
3327
public function __construct(
34-
GetQuoteAddress $getQuoteAddress,
3528
AssignShippingMethodToCart $assignShippingMethodToCart
3629
) {
37-
$this->getQuoteAddress = $getQuoteAddress;
3830
$this->assignShippingMethodToCart = $assignShippingMethodToCart;
3931
}
4032

@@ -50,11 +42,6 @@ public function execute(ContextInterface $context, CartInterface $cart, array $s
5042
}
5143
$shippingMethodInput = current($shippingMethodsInput);
5244

53-
if (!isset($shippingMethodInput['cart_address_id']) || empty($shippingMethodInput['cart_address_id'])) {
54-
throw new GraphQlInputException(__('Required parameter "cart_address_id" is missing.'));
55-
}
56-
$cartAddressId = $shippingMethodInput['cart_address_id'];
57-
5845
if (!isset($shippingMethodInput['carrier_code']) || empty($shippingMethodInput['carrier_code'])) {
5946
throw new GraphQlInputException(__('Required parameter "carrier_code" is missing.'));
6047
}
@@ -65,7 +52,7 @@ public function execute(ContextInterface $context, CartInterface $cart, array $s
6552
}
6653
$methodCode = $shippingMethodInput['method_code'];
6754

68-
$quoteAddress = $this->getQuoteAddress->execute($cart, $cartAddressId, $context->getUserId());
69-
$this->assignShippingMethodToCart->execute($cart, $quoteAddress, $carrierCode, $methodCode);
55+
$shippingAddress = $cart->getShippingAddress();
56+
$this->assignShippingMethodToCart->execute($cart, $shippingAddress, $carrierCode, $methodCode);
7057
}
7158
}

app/code/Magento/QuoteGraphQl/etc/schema.graphqls

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ input SetShippingMethodsOnCartInput {
115115
}
116116

117117
input ShippingMethodInput {
118-
cart_address_id: Int!
119118
carrier_code: String!
120119
method_code: String!
121120
}
@@ -188,7 +187,6 @@ type Cart {
188187
}
189188

190189
type CartAddress {
191-
address_id: Int
192190
firstname: String
193191
lastname: String
194192
company: String

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/CheckoutEndToEndTest.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,9 @@ public function testCheckoutWorkflow()
9292
$this->addProductToCart($cartId, $qty, $sku);
9393

9494
$this->setBillingAddress($cartId);
95-
$shippingAddress = $this->setShippingAddress($cartId);
95+
$shippingMethod = $this->setShippingAddress($cartId);
9696

97-
$shippingMethod = current($shippingAddress['available_shipping_methods']);
98-
$paymentMethod = $this->setShippingMethod($cartId, $shippingAddress['address_id'], $shippingMethod);
97+
$paymentMethod = $this->setShippingMethod($cartId, $shippingMethod);
9998
$this->setPaymentMethod($cartId, $paymentMethod);
10099

101100
$orderId = $this->placeOrder($cartId);
@@ -307,7 +306,6 @@ private function setShippingAddress(string $cartId): array
307306
) {
308307
cart {
309308
shipping_addresses {
310-
address_id
311309
available_shipping_methods {
312310
carrier_code
313311
method_code
@@ -325,8 +323,6 @@ private function setShippingAddress(string $cartId): array
325323
self::assertCount(1, $response['setShippingAddressesOnCart']['cart']['shipping_addresses']);
326324

327325
$shippingAddress = current($response['setShippingAddressesOnCart']['cart']['shipping_addresses']);
328-
self::assertArrayHasKey('address_id', $shippingAddress);
329-
self::assertNotEmpty($shippingAddress['address_id']);
330326
self::assertArrayHasKey('available_shipping_methods', $shippingAddress);
331327
self::assertCount(1, $shippingAddress['available_shipping_methods']);
332328

@@ -340,24 +336,22 @@ private function setShippingAddress(string $cartId): array
340336
self::assertArrayHasKey('amount', $availableShippingMethod);
341337
self::assertNotEmpty($availableShippingMethod['amount']);
342338

343-
return $shippingAddress;
339+
return $availableShippingMethod;
344340
}
345341

346342
/**
347343
* @param string $cartId
348-
* @param int $addressId
349344
* @param array $method
350345
* @return array
351346
*/
352-
private function setShippingMethod(string $cartId, int $addressId, array $method): array
347+
private function setShippingMethod(string $cartId, array $method): array
353348
{
354349
$query = <<<QUERY
355350
mutation {
356351
setShippingMethodsOnCart(input: {
357352
cart_id: "{$cartId}",
358353
shipping_methods: [
359354
{
360-
cart_address_id: {$addressId}
361355
carrier_code: "{$method['carrier_code']}"
362356
method_code: "{$method['method_code']}"
363357
}

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetOfflineShippingMethodsOnCartTest.php

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
namespace Magento\GraphQl\Quote\Customer;
99

1010
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId;
11-
use Magento\GraphQl\Quote\GetQuoteShippingAddressIdByReservedQuoteId;
1211
use Magento\Integration\Api\CustomerTokenServiceInterface;
1312
use Magento\TestFramework\Helper\Bootstrap;
1413
use Magento\TestFramework\TestCase\GraphQlAbstract;
@@ -23,11 +22,6 @@ class SetOfflineShippingMethodsOnCartTest extends GraphQlAbstract
2322
*/
2423
private $getMaskedQuoteIdByReservedOrderId;
2524

26-
/**
27-
* @var GetQuoteShippingAddressIdByReservedQuoteId
28-
*/
29-
private $getQuoteShippingAddressIdByReservedQuoteId;
30-
3125
/**
3226
* @var CustomerTokenServiceInterface
3327
*/
@@ -40,9 +34,6 @@ protected function setUp()
4034
{
4135
$objectManager = Bootstrap::getObjectManager();
4236
$this->getMaskedQuoteIdByReservedOrderId = $objectManager->get(GetMaskedQuoteIdByReservedOrderId::class);
43-
$this->getQuoteShippingAddressIdByReservedQuoteId = $objectManager->get(
44-
GetQuoteShippingAddressIdByReservedQuoteId::class
45-
);
4637
$this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class);
4738
}
4839

@@ -64,13 +55,11 @@ protected function setUp()
6455
public function testSetOfflineShippingMethod(string $carrierCode, string $methodCode, float $amount, string $label)
6556
{
6657
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
67-
$quoteAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute('test_quote');
6858

6959
$query = $this->getQuery(
7060
$maskedQuoteId,
7161
$methodCode,
72-
$carrierCode,
73-
$quoteAddressId
62+
$carrierCode
7463
);
7564
$response = $this->graphQlMutation($query, [], '', $this->getHeaderMap());
7665

@@ -111,22 +100,19 @@ public function offlineShippingMethodDataProvider(): array
111100
* @param string $maskedQuoteId
112101
* @param string $shippingMethodCode
113102
* @param string $shippingCarrierCode
114-
* @param int $shippingAddressId
115103
* @return string
116104
*/
117105
private function getQuery(
118106
string $maskedQuoteId,
119107
string $shippingMethodCode,
120-
string $shippingCarrierCode,
121-
int $shippingAddressId
108+
string $shippingCarrierCode
122109
): string {
123110
return <<<QUERY
124111
mutation {
125112
setShippingMethodsOnCart(input:
126113
{
127114
cart_id: "$maskedQuoteId",
128115
shipping_methods: [{
129-
cart_address_id: $shippingAddressId
130116
carrier_code: "$shippingCarrierCode"
131117
method_code: "$shippingMethodCode"
132118
}]

0 commit comments

Comments
 (0)