Skip to content

Commit

Permalink
try to extract first/last-names from fullname if not populated in fir…
Browse files Browse the repository at this point in the history
…st/last fields
  • Loading branch information
iesus committed Feb 7, 2018
1 parent 4fab06a commit ca8d2de
Showing 1 changed file with 30 additions and 16 deletions.
46 changes: 30 additions & 16 deletions app/code/community/Svea/Checkout/Model/Payment/CreateOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,28 +116,42 @@ protected function _addAddressToQuote($quote, $data)
$shippingAddress = new Varien_Object($data->getData('ShippingAddress'));
$customer = new Varien_Object($data->getData('Customer'));

$fakeFull = explode(' ', $billingAddress->getData('FullName'));
$fakeFirst = (end($fakeFull)) ? end($fakeFull) : $notNull;
$fakeLast = (isset($fakeFull[0])) ? $fakeFull[0] : $notNull;

$fakeFullShipping = explode(' ', $shippingAddress->getData('FullName'));
$fakeFirstShipping = (end($fakeFull)) ? end($fakeFull) : $notNull;
$fakeLastShipping = (isset($fakeFull[0])) ? $fakeFull[0] : $notNull;


$reference = ($data->getData('CustomerReference'))
? ($data->getData('CustomerReference'))
: false;
? ($data->getData('CustomerReference'))
: false;
$reference = (!$reference && $customer->getData('CustomerReference'))
? ($customer->getData('CustomerReference'))
: false;
? ($customer->getData('CustomerReference'))
: false;


$billingFirstname = ($billingAddress->getData('FirstName'))
? $billingAddress->getData('FirstName')
: $notNull;
? $billingAddress->getData('FirstName')
: $fakeFirst;
$billingFirstname = ($billingFirstname)
? $billingFirstname
: $notNull;
? $billingFirstname
: $fakeFirst;


if (true == $customer->getData('IsCompany')) {
$billingCompany = $billingAddress->getData('FullName');
$shippingCompany = $shippingAddress->getData('FullName');
$billingFirstname = ($reference)
? $reference
: $billingFirstname;
? $reference
: $billingFirstname;
}
$billingLastname = ($billingAddress->getData('LastName'))
? $billingAddress->getData('LastName')
: $notNull;
? $billingAddress->getData('LastName')
: $fakeLast;


$street = implode(
"\n",
Expand Down Expand Up @@ -170,13 +184,13 @@ protected function _addAddressToQuote($quote, $data)
$shippingFirstname = $reference;
} else {
$shippingFirstname = ($shippingAddress->getData('FirstName'))
? $shippingAddress->getData('FirstName')
: $notNull;
? $shippingAddress->getData('FirstName')
: $fakeFirstShipping;
}

$shippingLastname = $shippingAddress->getData('LastName')
? $shippingAddress->getData('LastName')
: $notNull;
? $shippingAddress->getData('LastName')
: $fakeLastShipping;

$street = implode(
"\n",
Expand Down

0 comments on commit ca8d2de

Please sign in to comment.