MyListing Club

Autocomplete WooCommerce Orders

Building better MyListing websites. One code snippet at a time.

Overview

The Autocomplete WooCommerce Orders code snippet will automatically complete orders for all virtual/downloadable products.

For MyListing websites, orders placed under a Listing Package are considered a virtual product, and the same goes for Listing Subscription Packages.

The question of “why are all my orders stuck with processing status?” comes up quite often, and while it’s perfectly fine to leave MyListing orders with a “processing” status, some website owners like to see those orders as “completed”.

Implementation

  1. Grab the code snippet.
  2. Follow the provided instructions.
  3. Save your changes.
				
					//// INSTRUCTIONS: 
//// Copy and paste the code snippet below into the child theme's functions.php file.
//// You can edit the functions.php file from your WordPress dashboard (Appearance > Theme Editor) or via FTP.

--------------------------- CODE SNIPPET IS BELOW THIS LINE --------------------------- 

// AUTOCOMPLETE 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' );
}