How to Make Purchase Order Number Optional in Magento 2

How to Make Purchase Order Number Optional in Magento 2

Purchase Order (PO) is one of the payment methods in Magento 2 that allow commercial customers to pay for authorized purchases by referencing the PO number.

This payment method is usually applied for wholesale orders. In order to configure the purchase order, we have to set “Yes” in the “enabled” option of the ‘Purchase Order’ section from Stores > Settings > Configuration > Sales.

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.

How to Make Purchase Order Number Optional in Magento 2

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.

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?

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 make purchase order number optional in Magento 2.

Steps to Make Purchase Order Number Optional in Magento 2

  1. Copy the below file
    If the purchaseorder-form.html file already exists, then edit that file.
  2. Search the below code in the purchaseorder-form.html file.
  3. Replace the above code with
  4. Use the below code in your custom module’s plugin file di.xml at app/code/[Vendor]/[Module]/etc

  5. Create Purchaseorder.php file at app/code/[Vendor]/[Module]/Plugin/Model

After applying the above code, one can place an order without entering a purchase order.

How to Make Purchase Order Number Optional in Magento 2

That’s it.

If you have queries regarding this blog, feel free to ask in the Comments section below.

I would be happy to answer your question.

Do consider sharing this post with Magento Community via social media.

Thank you.

Get Weekly Updates

Never miss Magento tips, tricks, tutorials, and news.

Thank you for subscribing.

Something went wrong.

(based on 10 Reviews)

He has been with Meetanshi for more than two years now as a Magento developer. A silent guy whom you can always find solving clients' issues, is an avid reader too.

Leave a reply:

Your email address will not be published.