2

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.

2 Answers 2

3

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

3
  • from which version can I find this version? I have 1.9.0.1 and I can't find it
    – gerosalesc
    Oct 27, 2016 at 15:43
  • I've set the country in optional code. but it's not working.
    – Kailas
    Feb 2, 2017 at 5:14
  • If you're using the RWD theme (or a theme based on it) then you also need to add some CSS to remove the asterisk - label[for="billing:postcode"].required:after {display: none;} - they hid the original asterisk and added one via a pseudo element, but didn't account for people changing that setting in the admin. Aug 8, 2019 at 20:30
0

You need to make sure you are viewing the "DEFAULT" screen view, it won't show if yiou are viewing in any other store view

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.