Woocommerce duplicate order via Class API?
I’m using Woocommerce to manage a number of orders. I have an action where I would like to duplicate an existing order. In other words, I want to create a new order that has a new order number but everything else is identical (user, billing info, items, totals, etc).
I want to do it from the theme’s functions.php file. I am using a woocommerce hook to trigger my custom function which currently finds the referenced order, then I need to create a duplicate of it (new order id of course).
I thought to use
WC_Order()to do it, but that doesn’t capture items. I thought to write directly to the DB using
$wpdb, but that is 4 tables to update with a whole lot of dependencies. Is there not something as simple as
$new = new WC_Order(); $new->save();?
- The topic ‘Woocommerce duplicate order via Class API?’ is closed to new replies.