Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace Magento\QuoteGraphQl\Model\Cart;

use Magento\Customer\Model\Address\AbstractAddress;
use Magento\Framework\Api\ExtensibleDataObjectConverter;
use Magento\Quote\Api\Data\AddressInterface;
use Magento\Quote\Model\Quote\Address as QuoteAddress;
Expand Down Expand Up @@ -41,28 +40,37 @@ public function execute(QuoteAddress $address): array
$addressData = $this->dataObjectConverter->toFlatArray($address, [], AddressInterface::class);
$addressData['model'] = $address;

$addressData = array_merge($addressData, [
'country' => [
'code' => $address->getCountryId(),
'label' => $address->getCountry()
],
'region' => [
'code' => $address->getRegionCode(),
'label' => $address->getRegion()
],
'street' => $address->getStreet(),
'items_weight' => $address->getWeight(),
'customer_notes' => $address->getCustomerNotes()
]);
$addressData = array_merge(
$addressData,
[
'country' => [
'code' => $address->getCountryId(),
'label' => $address->getCountry()
],
'region' => [
'code' => $address->getRegionCode(),
'label' => $address->getRegion()
],
'street' => $address->getStreet(),
'items_weight' => $address->getWeight(),
'customer_notes' => $address->getCustomerNotes()
]
);

if (!$address->hasItems()) {
return $addressData;
}

$addressItemsData = [];
foreach ($address->getAllItems() as $addressItem) {
if ($addressItem instanceof \Magento\Quote\Model\Quote\Item) {
$itemId = $addressItem->getItemId();
} else {
$itemId = $addressItem->getQuoteItemId();
}

$addressItemsData[] = [
'cart_item_id' => $addressItem->getQuoteItemId(),
'cart_item_id' => $itemId,
'quantity' => $addressItem->getQty()
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public function testGetAvailableShippingMethods()
'value' => 10,
'currency' => 'USD',
],
'base_amount' => null,
];
self::assertEquals(
$expectedAddressData,
Expand Down Expand Up @@ -135,25 +136,46 @@ private function getQuery(string $maskedQuoteId): string
query {
cart (cart_id: "{$maskedQuoteId}") {
shipping_addresses {
available_shipping_methods {
amount {
value
currency
}
carrier_code
carrier_title
error_message
method_code
method_title
price_excl_tax {
value
currency
}
price_incl_tax {
value
currency
}
cart_items {
cart_item_id
quantity
}
available_shipping_methods {
amount {
value
currency
}
carrier_code
carrier_title
error_message
method_code
method_title
price_excl_tax {
value
currency
}
price_incl_tax {
value
currency
}
base_amount {
value
currency
}
carrier_code
carrier_title
error_message
method_code
method_title
price_excl_tax {
value
currency
}
price_incl_tax {
value
currency
}
}
}
}
}
Expand Down