0

I'm sure there must be a simple way to programatically create a new order from the current checkout data in WooCommerce but I can't find it anywhere.

I have $order = wc_create_order(); $order->update_status('pending', 'order_note');

but I need all products and shipping etc added to the order exactly as it would be if the order was processed. I really just need whatever is on the checkout page processed into an order.

Surely this is a simple command?

Thanks

EDIT:

So I now have added all billing and shipping address details in with a long, laborious process. But now I need the shipping data......

$shipping_total = WC()->cart->get_shipping_total();
$order->set_shipping_total( $shipping_total );

The first line gets the amount but the second line doesn't seem to do anything. I think that I need to add in an entire shipping method to have the order list properly with full shipping info?

Why isn't there a 'Make order from checkout' function?

Thanks

RobertyBob
  • 803
  • 1
  • 8
  • 20
  • I did something similar a while ago https://stackoverflow.com/a/59544491/11987538 can this help you further? – 7uc1f3r Mar 17 '20 at 17:41
  • @7uc1f3r - many thanks - not exactly the same situaton but does tend to confirm that I need to copy each part of the details into an order in turn so will try that – RobertyBob Mar 18 '20 at 10:46
  • Ok so this helped get details into the order but now I have to try to get the chosen shipping data into it.... why is this so difficult? – RobertyBob Mar 18 '20 at 13:08

0 Answers0