Join

Autocomplete WooCommerce Orders

Don't want to mess with code snippets? Request for this to be a feature of MyListing Pro.

Instructions

  1. Create a new PHP code snippet.
  2. Copy the contents of code snippet below.
  3. Paste the contents into your code snippet.
  4. Review any notes that I’ve provided.
  5. Save and enable the code snippet.
  6. Test.

Snippet

This 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 “Why are all my orders stuck with processing status?” comes up quite often. While it’s perfectly fine to leave MyListing orders with a “processing” status, some website owners like to see those orders as “completed.”

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