1

I need to do some customization to my store but I don't know how to create a WooCommerce Order in PHP with WC_Order class. How can I accomplish that?

This is the code I've tried:

//Here I try to create a new order
$order_fab = new WC_Order();
//I save the new order ID
$order_fab_id = $order_fab->id; 
//I clone the original order
$order_fab = $order;
//restore the new order ID
$order_fab->id = $order_fab_id;
LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
Douglas Soares
  • 71
  • 1
  • 1
  • 8

1 Answers1

0

You might need to use the create_order method from WC_Checkout class. You can also take a look at the function that handles the checkout process. That's where the order is created.

Alexandru Furculita
  • 1,374
  • 9
  • 19