Create a WooCommerce Order Dynamically
Posted on This might be outdated!
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
[…] Ref: Create a WooCommerce Order Dynamically […]
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.
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?