Create a WooCommerce Order Dynamically

Alright, so you’d like to create an order dynamically within WooCommerce? Well, let me tell you you found the right post!

Here is a super small snippet that will allow you to create a new order on the fly and dynamically when the function is triggered, simply load the function when needed and adjust it. You could easily improve it by adding  a lot of custom fields, but this is not the 1st intention of this post! Enjoy

3 responses to “Create a WooCommerce Order Dynamically”

  1. We are working on a project that requires creating order dynamically. Isn’t there a function where you specify the product ID and number of item to add to cart available in WooCommerce?

    Oh I see. the ‘add_product’ method in wc_create_order() object can be used.

    Thanks.

  2. About this line… update_status(‘Completed’….. shouldn’t be this ‘wc-completed’ instead of ‘Completed’ and also how do i assign this order to a customer?

Leave a Reply