0

On my theme, the customer is allowed to proceed to the payment page of the checkout without having to add a Postcode, despite it being set as required. The other fields (Street, City) are required and validate correctly when they're left empty (the user is prevented from proceeding to the next step).

Any ideas why this is the case?

4
  • The Js form doesn't validate? Jan 5, 2017 at 17:09
  • Correct. The 'This is a required field.' doesn't appear and just allows the user to proceed
    – Mitch7663
    Jan 5, 2017 at 17:18
  • How about your issue? Jan 10, 2017 at 15:43
  • No, neither option worked :-(
    – Mitch7663
    Jan 15, 2017 at 22:33

2 Answers 2

1

On the checkout page, by default, the Postal Code are required field.

vendor/magento/module-checkout/view/frontend/layout/checkout_index_index.xml

<item name="postcode" xsi:type="array">
    <!-- post-code field has custom UI component -->
    <item name="component" xsi:type="string">Magento_Ui/js/form/element/post-code</item>
    <item name="validation" xsi:type="array">
        <item name="required-entry" xsi:type="string">true</item>
    </item>
</item>

enter image description here

So, you should check this field in your custom layout. Make sure the Required validation is enabled.

Additionally, if you want to make this attribute to be required on the server side also, you can use a simple query to :

UPDATE eav_attribute a SET a.`is_required` = 1 WHERE a.`attribute_code` = 'postcode';
3
  • I'm aware. But mine isn't.
    – Mitch7663
    Jan 7, 2017 at 8:41
  • Your custom theme has this field? Jan 7, 2017 at 8:43
  • We have Luma theme in use and it is not validating ZIP and let's all ZIP's through. Just a warning. That checkout_index_index.xml is not present in Luma.
    – Webninja
    Aug 16, 2017 at 18:09
0
  • In Magento 2 we can specify the Zip/Postal Code is Optional for countries.

  • In Magento admin Go to Stores > Configuration >General > General

  • for "Zip/Postal Code is Optional for" = Select countries for which you want to zip code option

  • Save
  • Flush cache

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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