1

i want to remove middle name & last name on checkout page only. from billing & shipping section. after analyse page code i found that. first/middle/last name coming from a file name.phtml path given below.

frontend/base/default/template/customer/widget/name.phtml

now i am able to remove middle/last name from here (of-course i am not editing core file & made exact path in my theme and paste that file which works OK)

but when i remove it from here. its also removed from registration page. So please tell me exactly what i have to do ?

my magento version is 1.9.X.X

  • My main issue is - when i am commenting last name in file its also removed from registration page

1 Answer 1

2

Try this,

Note : Don't Edit Core File Make a copy of Local File then edit

It will remove mandatory fields of First Name & Last Name.

UPDATE eav_attribute SET is_required = 0 WHERE attribute_code = 'lastname'

/app/code/local/Mage/customer/Model/Address/Abstract.php:

 /* if (!Zend_Validate::is($this->getLastname(), 'NotEmpty')) {
         $this->addError(Mage::helper('customer')->__('Please enter the last name.'));
     }
*/

/app/code/local/Mage/customer/Model/Customer.php

/*        if (!Zend_Validate::is( trim($this->getLastname()) , 'NotEmpty')) {
        $errors[] = Mage::helper('customer')->__('The last name cannot be empty.');
    }
*/

/app/code/local/Mage/customer/etc/config.xml

<lastname>
                    <billing>1</billing>
                    <shipping>1</shipping>
                    **<required>0</required>** // change from 1 to 0
                    <mapped>1</mapped>
     </lastname>
13
  • it will remove last name form checkout page & not affect registration page right ? Commented Sep 18, 2016 at 18:40
  • it will affect all page because same file use all place
    – Magento 2
    Commented Sep 18, 2016 at 18:47
  • but my main issu is this. because when i am commenting last name in file its also removed from registration page Commented Sep 18, 2016 at 18:52
  • don't remove in name.phtml just remove require class
    – Magento 2
    Commented Sep 18, 2016 at 19:04
  • i tried it. but its not working. first i made local file and edit in it. but it was not working again i edited core file but still not working. cleared all cache, reindex & recompile but still not working. last name is still required. Commented Sep 19, 2016 at 18:43

Your Answer

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

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