Skip to content

Commit

Permalink
Merge pull request #965 from mailchimp/Issue963-2.2
Browse files Browse the repository at this point in the history
closes #963 for magento 2.2
  • Loading branch information
gonzaloebiz authored Feb 14, 2020
2 parents 52cf084 + f381d44 commit 3135e4b
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions Model/Api/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,19 @@ protected function GeneratePOSTPayload(\Magento\Sales\Model\Order $order, $mailc
$data['billing_address']["address1"] = $street[0];
}

if (count($street) > 1) {
if (array_key_exists(1, $street)) {
$address["address2"] = $street[1];
$data['billing_address']["address2"] = $street[1];
}
if (array_key_exists(2, $street)) {
if (array_key_exists('address2',$address)) {
$address["address2"] = $address['address2'] . ", " . $street[2];
$data['billing_address']["address2"] = $data['billing_address']["address2"] . ", " . $street[2];
} else {
$address["address2"] = $street[2];
$data['billing_address']["address2"] = $street[2];
}
}

if ($billingAddress->getCity()) {
$address["city"] = $billingAddress->getCity();
Expand Down Expand Up @@ -479,15 +488,20 @@ protected function GeneratePOSTPayload(\Magento\Sales\Model\Order $order, $mailc
if ($shippingAddress->getName()) {
$data['shipping_address']['name'] = $shippingAddress->getName();
}

if (isset($street[0]) && $street[0]) {
$data['shipping_address']['address1'] = $street[0];
if ($street[0]) {
$data['shipping_address']["address1"] = $street[0];
}

if (isset($street[1]) && $street[1]) {
$data['shipping_address']['address2'] = $street[1];
if (array_key_exists(1, $street)) {
$data['shipping_address']["address2"] = $street[1];
}
if (array_key_exists(2, $street)) {
if (array_key_exists('address2',$data['shipping_address'])) {
$data['shipping_address']["address2"] = $data['shipping_address']["address2"] . ", " . $street[2];
} else {
$data['shipping_address']["address2"] = $street[2];
}
}

if ($shippingAddress->getCity()) {
$data['shipping_address']['city'] = $shippingAddress->getCity();
}
Expand Down

0 comments on commit 3135e4b

Please sign in to comment.