Magento – Make zip/postal code field required in ‘Estimate Shipping and Tax’ section – Shopping Cart page

formsshipping

Referring to the 'Estimate Shipping and Tax' section on Shopping Cart page – Magento EE 1.12.0.0, by default the 'Country', 'State/Province' and 'Zip/Postal Code' are not required.

enter image description here

This block is in the following template
frontend\enterprise\default\template\checkout/cart/shipping.phtml

As in the code snippet below, the 'required' (CSS) class is added only if $this->isZipCodeRequired() is set to true.

    <label for="postcode"<?php if ($this->isZipCodeRequired()) echo ' class="required"' ?>>
<?php if ($this->isZipCodeRequired()) echo '<em>*</em>' ?>
<?php echo $this->__('Zip/Postal Code') ?></label>

My question is: where is Magento checking for these values and can they be set in Magento Admin?

Note that the field "Postal Code is Optional for the following countries" in Magento Admin may not be an answer for this as, the above code snippet doesn't depend on the country.

Best Answer

If you want to make it required no matter what, just hard-code it in the template. It should be on the input, not just the label.

<label for="postcode" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
   <div class="input-box">
      <input class="input-text validate-postcode required-entry" type="text" id="postcode" name="estimate_postcode" value="<?php echo $this->escapeHtml($this->getEstimatePostcode()) ?>" />
   </div>