19

Since upgrading to the latest version of Magento, I noticed that a new entry has appeared on the checkout page asking for the customers middle name/initial.

How do I remove the entry "Middle name/initial" from the checkout page?

5 Answers 5

49

How the Magento 1.9.2.1 update affects Middle Name

First, the solution

I had the same issue when updating to Magento CE 1.9.2.1 from Magento CE 1.9.2.0. The update caused Middle Name to display, but when I checked the admin System > Configuration > Customers > Customer Configuration > Name and Address Options the "Show Middle Name (initial)" setting was already displaying "No" — which is what I wanted. I changed the setting to "Yes" and then back to "No" before clicking "Save Config", and this immediately removed Middle Name/Initial from Checkout when I refreshed the page.

The Database

In my case, I am working on updating a store from Magento 1.8.x to Magento 1.9.x. It is in my development environment that I updated from 1.9.2.0 to 1.9.2.1. In order to get the live site up-to-date when we launch the upgrade from 1.8.x to 1.9.x, we will need to update many of the admin settings, which we plan on doing directly in the database with a query. In the database, you can see how Magento changes the Middle Name setting.

The displayed Admin setting can be misleading

The table `core_config_data` handles the admin setting for "Show Middle Name (initial) with the record where `core_config_data`.`path`='customer/address/middlename_show'.

This record holds the setting in the `value` field (0="No", 1="Yes"). This field is not changed when the middle name appears by upgrading to Magento CE 1.9.2.1. If you save a change to the "Show Middle Name (initial)" in the admin settings after Magento makes changes during the update to 1.9.2.1, it will change the `core_config_data` value here.

The update to 1.9.2.1 did not change the record on `core_config_data`, and therefore what is displayed in the admin settings. But, the update does change a different record of a different table.

The actual middle name visibility is in `customer_eav_attribute`

In my many dev instances of Magento, the table `eav_attribute` has 2 "middle name" `attribute_code`(s), the `attribute_id`(s) being 6 and 21. The `customer_eav_attribute` table sets the visibility of the attribute with a field `is_visible`.

  • In my live 1.8.x environment, `attribute_id`(s) 6 and 21 had `is_visible` = 0.
  • After updating the dev to Magento CE 1.9.2.1 from Magento CE 1.9.2.0, it became `is_visible` = 1.
  • After I toggled and saved the admin "Show Middle Name (initial)" to "No", `is_visible`=0 again and the Middle Name/Initial field disappeared from Checkout.

Summary

The Magento CE 1.9.2.1 update flipped the Middle Name setting in the `customer_eav_attribute` table without affecting what is displayed in the Magento admin under the "Show Middle Name (Initial)" setting. You can fix it the way the setting is normally adjusted in the admin, without making far-reaching template adjustments, by toggling the "Show Middle Name (Initial)" setting.

Side note

If for some reason you need to transfer this admin setting across multiple copies of a store, or in a batch of admin updates, like while upgrading a store to match a dev environment... You can use the following SQL statement for this setting (provided you know that "middle name" is `attribute_id` 6 and 21 in your store. This is standard to Magento, but to be safe, double-check your `eav_attribute` table first.).

UPDATE customer_eav_attribute SET is_visible = 0 WHERE attribute_id IN (6, 21);

1
  • fix on magento 1.9.2.1 works fine for me
    – Fra
    Oct 22, 2015 at 10:09
5

The technical answer

The system config option has got a backend model (Mage_Adminhtml_Model_System_Config_Backend_Customer_Show_Customer) whose _afterSave method makes the same change in the customer EAV attribute (table: customer_eav_attribute).

The system config option value and the EAV attribute is_visible value might not necessarily be in sync (either because of a Magento upgrade, or if the config option was changed programmatically, or any other reason).

Flipping the switch a couple of times will fix it, or, if you're like me and use install/upgrade scripts for everything, you can do the following :

Mage::getModel('core/config')
    ->saveConfig('customer/address/middlename_show', 0);    

try {

    $attribute = Mage::getSingleton('eav/config')
        ->getAttribute('customer', 'middlename')
        ->setIsVisible(0)
        ->save();

    $attribute = Mage::getSingleton('eav/config')
        ->getAttribute('customer_address', 'middlename')
        ->setIsVisible(0)
        ->save();

} catch (Exception $e) {
    Mage::logException($e);
    throw $e;
}
1
  • 1
    Thanks, working great. You should add the code for the customer address attribute as well: $attribute = Mage::getSingleton('eav/config') ->getAttribute('customer_address', 'middlename') ->setIsVisible(0) ->save(); Dec 16, 2015 at 9:08
2

The easiest way:

Magento ver. 1.9.2.1

System > Configuration > Customers > Customer configuration > Name and Address Options

Show Middle Name (initial) = No

enter image description here

2
  • This was already set.
    – SR_Magento
    Aug 30, 2015 at 9:58
  • Just select Yes ->save . again select No->save . refresh cache and see. Mar 1, 2017 at 6:47
0

Removing {{depend middlename}}{{var middlename}} like @sr_magento suggests in his answer actually does not remove remove the Show Middle Name (initial) field from the checkout page itself. It only removes it from the areas where the customer address info is rendered/printed, like in the admin area, PDF's and email templates.

There is no need for removing the field from the email templates. This is overkill and you would have to add those entries to the email templates again in case you decide to enable the Show Middle Name(initial) in the future.

I have noticed this glitch too, after updating from Magento CE 1.9.2.0 to Magento CE 1.9.2.1 using the Magento downloader. The update seems to adjust the setting for Show Middle Name (initial) under

System > Configuration > Customers > Customer Configuration > Name and Address Options

from "No" to "Yes". It happened to me in several stores on different servers.

To undo this simply set it back to "No" and save config. The Show Middle Name (initial) field will no longer be displayed on the checkout page.

1
  • @sr_magento Your method may work (although I'm not sure why, I suspect simply saving the config does the trick) but your reasoning is incorrect. Changing the Address Templates like you suggest does not change the Checkout Page input fields in the frontend of the store. It only effects the templates for printing addresses. Please read the following documentation. You're right about the customer areas in the admin panel. I will rephrase this part of my answer.
    – MatthijsIJ
    Aug 25, 2015 at 7:59
0

If you want to remove directly from file then

Open following file

app=> design=> frontend=> base=> default=> template=> customer=> widget=> name.phtml

search for if ($this->showMiddlename()) comment out or remove that complete if statement

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.