I am trying to code Wordpress Woocommerce so all new orders are marked as "complete" by order status. The code is not working. What am I doing wrong?
I added this to functions.php:
function autocomplete_orders() {
add_action('woocommerce_thankyou', 'autocomplete_all_orders');
/**
* sp_autocomplete_all_orders
*
* Register custom tabs Post Type
*
* @param int $order_id
*
* @return null
*/
function autocomplete_all_orders($order_id) {
global $woocommerce;
if (!$order_id)
return;
$order = new WC_Order($order_id);
$order->update_status('completed');
}
}