Skip to content

Commit c0994b4

Browse files
committed
MAGETWO-69848: Fix #9924, prefill prefix and suffix in checkout shipping address #9925
1 parent 47d32b3 commit c0994b4

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php

+23-5
Original file line numberDiff line numberDiff line change
@@ -318,14 +318,32 @@ protected function getDefaultValue($attributeCode)
318318
if ($attributeCode === 'country_id') {
319319
return $this->directoryHelper->getDefaultCountry();
320320
}
321-
if (!$this->getCustomer()) {
321+
322+
$customer = $this->getCustomer();
323+
if ($customer === null) {
322324
return null;
323325
}
324-
if (in_array($attributeCode, ['prefix', 'firstname', 'middlename', 'lastname', 'suffix'])) {
325-
$methodName = 'get' . str_replace(' ', '', ucwords(str_replace('_', ' ', $attributeCode)));
326-
return $this->getCustomer()->{$methodName}();
326+
327+
$attributeValue = null;
328+
switch ($attributeCode) {
329+
case 'prefix':
330+
$attributeValue = $customer->getPrefix();
331+
break;
332+
case 'firstname':
333+
$attributeValue = $customer->getFirstname();
334+
break;
335+
case 'middlename':
336+
$attributeValue = $customer->getMiddlename();
337+
break;
338+
case 'lastname':
339+
$attributeValue = $customer->getLastname();
340+
break;
341+
case 'suffix':
342+
$attributeValue = $customer->getSuffix();
343+
break;
327344
}
328-
return null;
345+
346+
return $attributeValue;
329347
}
330348

331349
/**

0 commit comments

Comments
 (0)