How To

Magento 2: How to Fix Customer Name Prefix/Suffix Showing as Numbers in Address

Hello Magento Friends,

In this blog, we will learn about How to Fix Customer Name Prefix/Suffix Showing as Numbers in Address in Magento 2.

Prefixes and Suffixes are added to customers’ names in order to group them based on their marital status, qualification, etc. Learn How to Add Prefix and Suffix in Magento 2.

In Magento 2, order summary billing and shipping address instead of prefix/suffix of customer’s name, it is displayed number. Instead of name prefixes like Mr., Mrs., or Dr., it displays numbers. Go ahead to know the solution to this issue.

Steps to Fix Customer Name Prefix/Suffix Showing as Numbers in Address in Magento 2:

Step 1: First, we need to create a “di.xml” file inside the extension etc directory of our extension at the following path.

app\code\Vendor\Extension\etc

Now add the code as follows

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Customer\Model\Options">
      <plugin name="customer_prefix_issue" type="Vendor\Extension\Plugin\ChangePrefixOption"/>
   </type>
</config>

Step 2: After that, we need to create a “ChangePrefixOption.php” file inside the extension at the following path.

app\code\Vendor\Extension\Plugin

And append the below code-snippet

<?php
namespace Vendor\Extension\Plugin;
use Magento\Customer\Model\Options;

class ChangePrefixOption
{
    public function afterGetNamePrefixOptions(Options $subject, array|bool $result): array|bool
    {
        if (!is_array($result))
        {
            return $result;
        }
        $prefixArray = [];
        foreach ($result as $prefixValue)
        {
            $prefixArray[$prefixValue] = $prefixValue;
        }
        return $prefixArray;
    }
}

Conclusion:

Hence, using the above steps, you can Fix Customer Name Prefix/Suffix Showing as Numbers in Address in Magento 2. If you face any difficulty, share it with me through the comment box. Share the solution with your friends and stay in touch with us.

Happy Coding!

Click to rate this post!
[Total: 3 Average: 5]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate 🎖️ Certified Magento Developer👨‍💻. He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fond❤️ of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.🏏

Recent Posts

Five Essential Payroll Compliance Tips for eCommerce Startups

Are you setting up a payroll system for your eCommerce startup? Ensuring compliance with myriad…

15 hours ago

Optimizing Laravel Blade: Unlocking Advanced Fetcher Techniques

In the expansive universe of Laravel development, Blade serves as the stellar templating engine, propelling…

16 hours ago

Magento 2: Add Quantity Increment and Decrement on Category Page

Hello Magento Friends, In this blog, we will discuss about adding quantity increment and decrement…

3 days ago

How to Integrate ChatGPT with Laravel Application?

In this guide, we'll explore how to integrate ChatGPT, an AI-powered chatbot, with a Laravel…

6 days ago

What are Net Sales? How to Calculate Your Net Sales?

In the world of business, understanding financial metrics is crucial for making informed decisions and…

1 week ago

Magento 2 Extensions Digest April 2024 (New Release & Updates)

Welcome to the MageComp Monthly Digest, where we bring you the latest updates, releases, and…

1 week ago