I need to add the ZIP field on the sign-up page.

I enabled the setShowAddressFields parameter in order to show address fields, then I overrode the file /template/persistent/register.phtml to show only the ZIP field.

Of course, the address validation fails and so I googled for the solution, but I only found some indication to modify the DB and the Zend validation function. I don't want do that, because I need address fields required during the checkout process.

So, any idea to simply show and store the ZIP field?


2 Answers 2


Please create local.xml in your theme layout folder.

Refer the code below in local.xml:

<layout version="0.1.0">

      <reference name="customer_form_register">   
        <action method="setShowAddressFields">



In customer.xml (current theme layout), add the below code in customer_account_create node:

<action method="setShowAddressFields"><value>true</value></action>

so it look like

<reference name="content">          
    <block type="customer/form_register" name="customer_form_register" template="customer/form/register.phtml">
       <action method="setShowAddressFields"><value>true</value></action>
       <block type="page/html_wrapper" name="customer.form.register.fields.before" as="form_fields_before" translate="label">
             <label>Form Fields Before</label>

Clear the cache after added code.

Please find the _basicCheck function in Mage_Customer_Model_Address_Abstract, this validating the registration required fields, so you have to rewrite this function _basicCheck.

Please refer this link its for telephone field (customize for zipcode field), have a look on this. Hope this will helps

  • thank you, but as I wrote in my question, I've already enabled the setShowAddressFields parameter. it works, but I need just the ZIP field, not the entire Address section.
    – apedic
    Nov 27, 2014 at 7:18
  • yeah you customize the register.phtml(just copy from base theme to your current theme template folder)
    – Venkat
    Nov 27, 2014 at 8:20
  • Already done, but it doesn't work because the others address fields are still required. I've to override Zend Validation, but I don't want to do it
    – apedic
    Nov 27, 2014 at 8:37
  • Please refer the edited part above, hope that will helps
    – Venkat
    Nov 27, 2014 at 8:39

Have a look at Mage_Customer_Model_Address_Abstract::validate() you will find this little gem:

if (empty($errors) || $this->getShouldIgnoreValidation()) {
            return true;

so, if your pre-set ShouldIgnoreValidation flag on the address object (billing and shipping), address validation will always result true.

However, if you do set that, you'd also not get any validation of the ZIP (or any address fields you may have as required) You would have to craft your own validation somewhere else.

Customer address data save is initiated in `Mage_Customer_Model_Resource_Customer::_afterSave

     * Save customer addresses and set default addresses in attributes backend
     * @param Varien_Object $customer
     * @return Mage_Eav_Model_Entity_Abstract
    protected function _afterSave(Varien_Object $customer)
        return parent::_afterSave($customer);

so you would most likely be able to use the _beforeSave event to inject the flag to the address objects. (not tested)

Alternatively, rewrite the method Mage_Customer_Model_Address_Abstract::validate() and place your own logic to skip validation when it is to be skipped.

Hope that at least helps you along. Good luck

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.