In Magento when we enable PO number (Purchase order) from the admin panel then it is a required field. To make it optional we have to create a plugin. There are the following steps:
- Make a copy of the file that is located here to your theme folder:
vendor/magento/module-offline-payments/view/frontend/web/template/payment/purchaseorder-form.html
- Remove the required class and data-validate. New code will look like this
<div class="field field-number required">
<label for="po_number" class="label">
<span><!-- ko i18n: 'Purchase Order Number'--><!-- /ko --></span>
</label>
<div class="control">
<input type="text"
id="po_number"
name="payment[po_number]"
data-validate="{required:true}"
data-bind='
attr: {title: $t("Purchase Order Number")},
value: purchaseOrderNumber'
class="input-text"/>
</div>
</div>
3. Download our module that will create an around plugin and it will bypass server-side validation.