diff --git a/app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php b/app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php index dcfe1cd5e2038..888b7fdbd0945 100644 --- a/app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php +++ b/app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php @@ -315,26 +315,35 @@ protected function getMultilineFieldConfig($attributeCode, array $attributeConfi */ protected function getDefaultValue($attributeCode) { + if ($attributeCode === 'country_id') { + return $this->directoryHelper->getDefaultCountry(); + } + + $customer = $this->getCustomer(); + if ($customer === null) { + return null; + } + + $attributeValue = null; switch ($attributeCode) { + case 'prefix': + $attributeValue = $customer->getPrefix(); + break; case 'firstname': - if ($this->getCustomer()) { - return $this->getCustomer()->getFirstname(); - } + $attributeValue = $customer->getFirstname(); break; case 'middlename': - if ($this->getCustomer()) { - return $this->getCustomer()->getMiddlename(); - } + $attributeValue = $customer->getMiddlename(); break; case 'lastname': - if ($this->getCustomer()) { - return $this->getCustomer()->getLastname(); - } + $attributeValue = $customer->getLastname(); + break; + case 'suffix': + $attributeValue = $customer->getSuffix(); break; - case 'country_id': - return $this->directoryHelper->getDefaultCountry(); } - return null; + + return $attributeValue; } /**