Skip to content

Commit ff0e6c0

Browse files
author
Vitaliy Boyko
committed
graphQl-889: base_amount marked as deprecated
1 parent db43c11 commit ff0e6c0

File tree

7 files changed

+7
-53
lines changed

7 files changed

+7
-53
lines changed

app/code/Magento/QuoteGraphQl/Model/Resolver/ShippingAddress/AvailableShippingMethods.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,8 @@ private function processMoneyTypeData(array $data, string $quoteCurrencyCode, St
9898
$data['amount'] = ['value' => $data['amount'], 'currency' => $quoteCurrencyCode];
9999
}
100100

101-
if (isset($data['base_amount'])) {
102-
/** @var Currency $currency */
103-
$currency = $store->getBaseCurrency();
104-
$data['base_amount'] = ['value' => $data['base_amount'], 'currency' => $currency->getCode()];
105-
}
101+
/** @deprecated The field should not be used on the storefront */
102+
$data['base_amount'] = null;
106103

107104
if (isset($data['price_excl_tax'])) {
108105
$data['price_excl_tax'] = ['value' => $data['price_excl_tax'], 'currency' => $quoteCurrencyCode];

app/code/Magento/QuoteGraphQl/Model/Resolver/ShippingAddress/SelectedShippingMethod.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,8 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
5858
'value' => $address->getShippingAmount(),
5959
'currency' => $address->getQuote()->getQuoteCurrencyCode(),
6060
],
61-
'base_amount' => [
62-
'value' => $address->getBaseShippingAmount(),
63-
'currency' => $currency->getCode(),
64-
],
61+
/** @deprecated The field should not be used on the storefront */
62+
'base_amount' => null,
6563
];
6664
} else {
6765
$data = [
@@ -70,6 +68,7 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
7068
'carrier_title' => $carrierTitle,
7169
'method_title' => $methodTitle,
7270
'amount' => null,
71+
/** @deprecated The field should not be used on the storefront */
7372
'base_amount' => null,
7473
];
7574
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ type SelectedShippingMethod {
244244
carrier_title: String
245245
method_title: String
246246
amount: Money
247-
base_amount: Money
247+
base_amount: Money @deprecated(reason: "The field should not be used on the storefront")
248248
}
249249

250250
type AvailableShippingMethod {
@@ -254,7 +254,7 @@ type AvailableShippingMethod {
254254
method_title: String @doc(description: "Could be null if method is not available")
255255
error_message: String
256256
amount: Money!
257-
base_amount: Money @doc(description: "Could be null if method is not available")
257+
base_amount: Money @deprecated(reason: "The field should not be used on the storefront")
258258
price_excl_tax: Money!
259259
price_incl_tax: Money!
260260
available: Boolean!

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ public function testGetAvailableShippingMethods()
6262
'value' => 10,
6363
'currency' => 'USD',
6464
],
65-
'base_amount' => [
66-
'value' => 10,
67-
'currency' => 'USD',
68-
],
6965
'carrier_code' => 'flatrate',
7066
'carrier_title' => 'Flat Rate',
7167
'error_message' => '',
@@ -176,10 +172,6 @@ private function getQuery(string $maskedQuoteId): string
176172
value
177173
currency
178174
}
179-
base_amount {
180-
value
181-
currency
182-
}
183175
carrier_code
184176
carrier_title
185177
error_message

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,6 @@ public function testGetSelectedShippingMethod()
7878
self::assertEquals(10, $amount['value']);
7979
self::assertArrayHasKey('currency', $amount);
8080
self::assertEquals('USD', $amount['currency']);
81-
82-
self::assertArrayHasKey('base_amount', $shippingAddress['selected_shipping_method']);
83-
$baseAmount = $shippingAddress['selected_shipping_method']['base_amount'];
84-
85-
self::assertArrayHasKey('value', $baseAmount);
86-
self::assertEquals(10, $baseAmount['value']);
87-
self::assertArrayHasKey('currency', $baseAmount);
88-
self::assertEquals('USD', $baseAmount['currency']);
8981
}
9082

9183
/**
@@ -188,7 +180,6 @@ public function testGetGetSelectedShippingMethodIfShippingMethodIsNotSet()
188180
self::assertNull($shippingAddress['selected_shipping_method']['carrier_title']);
189181
self::assertNull($shippingAddress['selected_shipping_method']['method_title']);
190182
self::assertNull($shippingAddress['selected_shipping_method']['amount']);
191-
self::assertNull($shippingAddress['selected_shipping_method']['base_amount']);
192183
}
193184

194185
/**
@@ -240,10 +231,6 @@ private function getQuery(string $maskedQuoteId): string
240231
value
241232
currency
242233
}
243-
base_amount {
244-
value
245-
currency
246-
}
247234
}
248235
}
249236
}

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetAvailableShippingMethodsTest.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ public function testGetAvailableShippingMethods()
5454
'value' => 10,
5555
'currency' => 'USD',
5656
],
57-
'base_amount' => [
58-
'value' => 10,
59-
'currency' => 'USD',
60-
],
6157
'carrier_code' => 'flatrate',
6258
'carrier_title' => 'Flat Rate',
6359
'error_message' => '',
@@ -144,10 +140,6 @@ private function getQuery(string $maskedQuoteId): string
144140
value
145141
currency
146142
}
147-
base_amount {
148-
value
149-
currency
150-
}
151143
carrier_code
152144
carrier_title
153145
error_message

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetSelectedShippingMethodTest.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,6 @@ public function testGetSelectedShippingMethod()
7070
self::assertEquals(10, $amount['value']);
7171
self::assertArrayHasKey('currency', $amount);
7272
self::assertEquals('USD', $amount['currency']);
73-
74-
self::assertArrayHasKey('base_amount', $shippingAddress['selected_shipping_method']);
75-
$baseAmount = $shippingAddress['selected_shipping_method']['base_amount'];
76-
77-
self::assertArrayHasKey('value', $baseAmount);
78-
self::assertEquals(10, $baseAmount['value']);
79-
self::assertArrayHasKey('currency', $baseAmount);
80-
self::assertEquals('USD', $baseAmount['currency']);
8173
}
8274

8375
/**
@@ -158,7 +150,6 @@ public function testGetGetSelectedShippingMethodIfShippingMethodIsNotSet()
158150
self::assertNull($shippingAddress['selected_shipping_method']['carrier_title']);
159151
self::assertNull($shippingAddress['selected_shipping_method']['method_title']);
160152
self::assertNull($shippingAddress['selected_shipping_method']['amount']);
161-
self::assertNull($shippingAddress['selected_shipping_method']['base_amount']);
162153
}
163154

164155
/**
@@ -195,10 +186,6 @@ private function getQuery(string $maskedQuoteId): string
195186
value
196187
currency
197188
}
198-
base_amount {
199-
value
200-
currency
201-
}
202189
}
203190
}
204191
}

0 commit comments

Comments
 (0)