Auto Complete Woo-commerce Orders

When a order is placed, the customer will pay for it, the order will be fulfilled and at which point the order will probably be marked as ‘Completed’.

 

This process is supported in WooCommerce and allows the order to go from ‘Pending’, to ‘Processing’, and finally to ‘Completed’ once the products have been sent out.

This is fine for orders where a physical item exists, but this seems not correct with virtual orders because there is no notion of postage or sending out items. Then after receiving the Payment it should be Auto Complete. Here are the snippet how we can auto complete the woocommerce orders.

Add the below mentioned code at the end of your functions.php file,
which is located in “wp-content/themes/your-theme-name/:” Then replace the existing code with this snippet:

/**
* Auto Complete all WooCommerce orders.
*/
add_action( ‘woocommerce_thankyou’, ‘custom_woocommerce_auto_complete_order’ );
function custom_woocommerce_auto_complete_order( $order_id ) {
if ( ! $order_id ) {
return;
}

$order = wc_get_order( $order_id );
$order->update_status( ‘completed’ );
}

If you are need more help our development team can help you to setup the Events Calender Pro + Woocommerce Tickets plugin setup.

You may also like

Leave a comment