Magento 1.9 – How to Change Zip/Postal Code to Not Required

checkoutmagento-1.9onepage-checkout

How to change required field of Zip/Postal code with "not required" from checkout page?
i have changed the lines 106-111 in app/design/frontend/base/default/template/persistent/checkout/onepage/billing.phtml

<div class="field">
                    <label for="billing:postcode"><?php echo $this->__('Zip/Postal Code') ?></label>
                    <div class="input-box">
                        <input type="text" title="<?php echo $this->__('Zip/Postal Code') ?>" name="billing[postcode]" id="billing:postcode" value="<?php echo $this->escapeHtml($this->getAddress()->getPostcode()) ?>" class="input-text validate-zip-international <?php// echo $this->helper('customer/address')->getAttributeValidationClass('postcode') ?>" />
                    </div>
                </div>

Also i have removed these lines from the file "app/code/core/Mage/Customer/Model/Address/Abstract.php"

$_havingOptionalZip = Mage::helper('directory')->getCountriesWithOptionalZip();
    if (!in_array($this->getCountryId(), $_havingOptionalZip)
        && !Zend_Validate::is($this->getPostcode(), 'NotEmpty')
    ) {
        $this->addError(Mage::helper('customer')->__('Please enter the zip/postal code.'));
    }

But it did not completely changed that field to not required. Because when i place order, it shows a message

"Zip/Postal Code" is a required value.

Best Answer

You can change that in admin panel, itself.

Navigate to

Admin > System > Configuration > General > Country Option > Postal Code is Optional for the following countries

You can select the countries for Zip/Postal Code optional.

enter image description here

Related Topic