Skip to content

Commit

Permalink
INTER-4546: Hydrate Shipping Address From Magento Quote (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephLeedy authored Aug 15, 2024
1 parent 63a17e2 commit 19fffea
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Model/Order/HydrateOrderFromQuote.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,14 @@ public function hydrate(CartInterface $quote, string $publicOrderId): void
{
$websiteId = (int)$quote->getStore()->getWebsiteId();
$billingAddress = $this->quoteToOrderAddressConverter->convert($quote->getBillingAddress());
$shippingAddress = null;

if ($quote->getIsVirtual()) {
$totals = $quote->getBillingAddress()->getTotals();
} else {
$totals = $quote->getShippingAddress()->getTotals();
$shippingDescription = $quote->getShippingAddress()->getShippingDescription();
$shippingAddress = $this->quoteToOrderAddressConverter->convert($quote->getShippingAddress());
}

list($fees, $discounts) = $this->getFeesAndDiscounts($totals);
Expand Down Expand Up @@ -123,6 +125,10 @@ public function hydrate(CartInterface $quote, string $publicOrderId): void
],
];

if ($shippingAddress !== null) {
$body['shipping_address'] = $this->addressConverter->convert($shippingAddress);
}

if ($quote->getCustomer()->getId()) {
$body['customer'] = [
'platform_id' => (string)$quote->getCustomerId(),
Expand Down
15 changes: 15 additions & 0 deletions Test/Integration/Model/Order/HydrateOrderFromQuoteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,21 @@ public function testHydratesOrderFromQuoteSuccessfully(bool $quoteItemHasWeight)
'shipping_total' => 0,
'order_total' => 2000,
],
'shipping_address' => [
'id' => null,
'business_name' => 'CompanyName',
'country_code' => 'US',
'country' => 'United States',
'city' => 'CityM',
'first_name' => 'John',
'last_name' => 'Smith',
'phone_number' => '3468676',
'postal_code' => '75477',
'province' => 'Alabama',
'province_code' => 'AL',
'address_line_1' => 'Green str, 67',
'address_line_2' => '',
],
'customer' => [
'platform_id' => '1',
'first_name' => 'John',
Expand Down

0 comments on commit 19fffea

Please sign in to comment.