Hello Magento Friends,

Hope all are doing well! Today’s subject matter is How to Programmatically Create Invoice using Root Script in Magento 2.

When an order is placed, Magento 2 order management system generates invoices. If you are accepting online payments via PayPal, Stripe, or other payment providers, an invoice is automatically generated.

But when an order is placed with cash on delivery or offline payments, the admin needs to create an invoice manually. Magento 2 Auto Invoice and Shipment extension can come as a savior for you to eliminate creating invoices manually. 

For now, follow the below steps to Programmatically Create Invoice using Root Script in Magento 2.

Steps to Programmatically Create Invoice using Root Script in Magento 2:

Step 1: Create invoicegenerate.php file in Magento root path and then add the below code

Step 2: After adding the above code, run the below URL to check whether the invoice is created or not.

https://yourdomain/invoicegenerate.php/

Conclusion:

This way you can Programmatically Create Invoice using Root Script in Magento 2. In addition to this, you can also Add Order ID, Customer IP Address in Invoice in Magento 2.

In case of any doubts, share the details in the comment box. Also, share the article via your social media platforms and among your friend’s groups. Stay in the know for more solutions.

Happy Reading!

Click to rate this post!
[Total: 6 Average: 5]