Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.

Commit d10e506

Browse files
committed
New schema for setting shipping methods
1 parent b4c032b commit d10e506

File tree

4 files changed

+356
-4
lines changed

4 files changed

+356
-4
lines changed

app/code/Magento/ConfigurableProductGraphQl/etc/module.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<module name="Magento_ConfigurableProduct"/>
1313
<module name="Magento_GraphQl"/>
1414
<module name="Magento_CatalogGraphQl"/>
15+
<module name="Magento_QuoteGraphQl"/>
1516
</sequence>
1617
</module>
1718
</config>

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ public function execute(QuoteAddress $address): array
4040
$addressData = $this->dataObjectConverter->toFlatArray($address, [], AddressInterface::class);
4141
$addressData['model'] = $address;
4242

43+
if ($address->getShippingMethod()) {
44+
list($carrierCode, $methodCode) = explode('_', $address->getShippingMethod(), 2);
45+
$shippingAmount = $address->getShippingAmount();
46+
}
47+
4348
$addressData = array_merge($addressData, [
4449
'country' => [
4550
'code' => $address->getCountryId(),
@@ -51,9 +56,10 @@ public function execute(QuoteAddress $address): array
5156
],
5257
'street' => $address->getStreet(),
5358
'selected_shipping_method' => [
54-
'code' => $address->getShippingMethod(),
59+
'carrier_code' => $carrierCode ?? null,
60+
'method_code' => $methodCode ?? null,
5561
'label' => $address->getShippingDescription(),
56-
'free_shipping' => $address->getFreeShipping(),
62+
'amount' => $shippingAmount ?? null
5763
],
5864
'items_weight' => $address->getWeight(),
5965
'customer_notes' => $address->getCustomerNotes()

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,15 @@ input CartAddressInput {
6060

6161
input SetShippingMethodsOnCartInput {
6262
cart_id: String!
63-
shipping_methods: [ShippingMethodForAddressInput!]!
63+
shipping_addresses: [ShippingMethodForAddressInput!]!
6464
}
6565

6666
input ShippingMethodForAddressInput {
6767
cart_address_id: Int!
68+
shipping_method: ShippingMethodInput!
69+
}
70+
71+
input ShippingMethodInput {
6872
carrier_code: String!
6973
method_code: String!
7074
}
@@ -140,7 +144,10 @@ type CartAddressCountry {
140144
}
141145

142146
type SelectedShippingMethod {
143-
amount: Float!
147+
carrier_code: String
148+
method_code: String
149+
label: String
150+
amount: Float
144151
}
145152

146153
type AvailableShippingMethod {
@@ -246,3 +253,8 @@ type CartItemSelectedOptionValuePrice {
246253
units: String!
247254
type: PriceTypeEnum!
248255
}
256+
257+
input CartItemDetailsInput {
258+
sku: String!
259+
qty: Float!
260+
}

0 commit comments

Comments
 (0)