I want to make the postcode filed a required filed in the checkout process. I am sure that by default, this IS required but for some reason, it isn't in my store.
I know there is entry in vendor/magento/module-checkout/view/frontend/layout/checkout_index_index.xml
that makes the filed required:
<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>
But I can't see my theme overwriting this file anywhere but just to be sure I added the original file from vendor to my theme folder. Still no luck.
How else would I debug this issue?
Running on:
- Magento 2.1.8
- Custom theme "Venustheme/cricket"
- Nginx
Best Answer
I found my problem...
Magento 2 has a built in feature that allows the user to specify countries for optional post code.
In that feature, you can remove validation for selected countries.
Settings can be found in: Admin Panel > Stores > Settings > Configuration > General > General > Country options > Zip/Postal Code is Optional for
You have to un-tick the "Use system value" and un-select the countries that you want the post code to be validated for.
I should have properly looked through configurations rather than jumping straight to the code... I hope someone will find this useful.