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');
}
}
function autocomplete_all_orders( $order_id ) {
if ( ! $order_id ) return;
$order = wc_get_order( $order_id );
$order->update_status( 'completed' );
}
add_action( 'woocommerce_thankyou', 'autocomplete_all_orders' );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.