Programmatically create quote and order with custom and configurable options | Magento2

Programmatically create quote and order with custom and configurable options | Magento2

In this blog, we will learn how to programatically create quote as well as order with and without custom options. We will implement it for all types of products: simple, configurable, bundled, grouped, downloadable and virtual products.

I will use this sample data to create quote and order:

The function createOrder function will create order with the sample data:

Now, By using this code, you can create quote and order in magento 2.

To use it with configurable product, pass super_attribute and so on for other types of products. In case of any issue ask your questions in comments.