{"id":1714,"date":"2021-04-19T05:20:27","date_gmt":"2021-04-19T05:20:27","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/make-purchase-order-number-optional-in-magento-2\/"},"modified":"2025-07-16T18:02:01","modified_gmt":"2025-07-16T12:32:01","slug":"make-purchase-order-number-optional-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/make-purchase-order-number-optional-in-magento-2\/","title":{"rendered":"How to Make Purchase Order Number Optional in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/experienceleague.adobe.com\/en\/docs\/commerce-admin\/stores-sales\/payments\/payments\" target=\"_blank\" rel=\"noreferrer noopener\">Purchase Order<\/a>\u00a0(PO) is one of the payment methods in\u00a0Magento 2\u00a0that allow commercial customers to pay for authorized purchases by referencing the PO number.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This payment method is usually applied for wholesale orders. In order to configure the purchase order, we have to set \u201cYes\u201d in the \u201cenabled\u201d option of the \u2018Purchase Order\u2019 section from Stores&nbsp;&gt;&nbsp;Settings&nbsp;&gt;&nbsp;Configuration &gt; Sales.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After applying the configuration for the purchase order, it displays at the checkout page while completing the payment method as shown in the below image.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/04\/Screenshot-at-April-9th-2021-10.45.19-am-1024x551.png\" alt=\"How to Make Purchase Order Number Optional in Magento 2\" class=\"wp-image-14384\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In most cases, agencies or any other business place wholesale orders in the store. If demanded order is available, the store owner can ship that product to the customer, but what if ordered products are not available? In that scenario, the customer registers their name, required stocks, and pay the total amount or decided half amount.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The customer gets a purchase order number, but what if the customer does not have a purchase order number and still wants to purchase the product?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the default behaviour of Magento 2, it will not allow placing an order without a purchase order as it is a required field. Use the below code and&nbsp;<strong><em>make purchase order number optional in Magento 2.<\/em><\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Steps to Make Purchase Order Number Optional in Magento 2<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">1. Copy the below file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">vendor\/magento\/module-offline-payments\/view\/frontend\/web\/template\/payment\/purchaseorder-form.html<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">app\/design\/frontend\/[Vendor]\/[Theme]\/Magento_OfflinePayments\/web\/template\/payment\/purchaseorder-form.html<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the purchaseorder-form.html file already exists, then edit that file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2. Search the below code in the purchaseorder-form.html file.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;div class=\"field field-number required\">\n    &lt;label for=\"po_number\" class=\"label\">\n        &lt;span>&lt;!-- ko i18n: 'Purchase Order Number'-->&lt;!-- \/ko -->&lt;\/span>\n    &lt;\/label>\n    &lt;div class=\"control\">\n        &lt;input type=\"text\"\n               id=\"po_number\"\n               name=\"payment[po_number]\"\n               data-validate=\"{required:true}\"\n               data-bind='\n                                attr: {title: $t(\"Purchase Order Number\")},\n                                value: purchaseOrderNumber'\n               class=\"input-text\"\/>\n    &lt;\/div>\n&lt;\/div><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">3. Replace the above code with<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;div class=\"field field-number\">\n    &lt;label for=\"po_number\" class=\"label\">\n        &lt;span>&lt;!-- ko i18n: 'Purchase Order Number'-->&lt;!-- \/ko -->&lt;\/span>\n    &lt;\/label>\n    &lt;div class=\"control\">\n        &lt;input type=\"text\"\n               id=\"po_number\"\n               name=\"payment[po_number]\"\n               data-bind='\n                                attr: {title: $t(\"Purchase Order Number\")},\n                                value: purchaseOrderNumber'\n               class=\"input-text\"\/>\n    &lt;\/div>\n&lt;\/div><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">4. Use the below code in your custom module\u2019s plugin file<strong>&nbsp;di.xml<\/strong>&nbsp;at&nbsp;<strong><strong>app\/code\/[Vendor]\/[Module]\/etc<\/strong><\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?xml version=\"1.0\"?>\n&lt;config xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n        xsi:noNamespaceSchemaLocation=\"urn:magento:framework:ObjectManager\/etc\/config.xsd\">\n\n    &lt;type name=\"Magento\\OfflinePayments\\Model\\Purchaseorder\">\n        &lt;plugin name=\"purchase_order_validate\" type=\"Vendor\\Module\\Plugin\\Model\\Purchaseorder\"\/>\n    &lt;\/type>\n&lt;\/config><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">5. Create&nbsp;<strong>Purchaseorder.php&nbsp;<\/strong>file at&nbsp;<strong><strong>app\/code\/[Vendor]\/[Module]\/Plugin\/Model<\/strong><\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nnamespace [Vendor]\\[Module]\\Plugin\\Model;\n\nclass Purchaseorder\n{\n    public function aroundvalidate($subject, $proceed)\n    {\n        \/\/ check PoNumber is empty or not\n        if (empty($subject->getInfoInstance()->getPoNumber())) {\n            return $this;\n        }\n        return $this;\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">After applying the above code, one can place an order without entering a purchase order.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/04\/Screenshot-at-April-9th-2021-10.46.46-am-1024x512.png\" alt=\"How to Make Purchase Order Number Optional in Magento 2\" class=\"wp-image-14383\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Also read:<\/strong>&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/magento-2-custom-order-number-extension-configuration\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Configure Magento 2 Custom Order Number Extension<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Do consider sharing this post with Magento Community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Purchase Order\u00a0(PO) is one of the payment methods in\u00a0Magento 2\u00a0that allow commercial customers to pay for authorized purchases by referencing the PO number. This payment&#8230;<\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1714","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1714","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1714"}],"version-history":[{"count":5,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1714\/revisions"}],"predecessor-version":[{"id":18114,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1714\/revisions\/18114"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1714"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1714"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1714"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}