Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Allow Customers to Complete a Processing Order in WooCommerce?

In WooCommerce, the completion of an order is a manual process done by the store manager. But in specific scenarios, such as with downloadable orders, this process may occur automatically.

Imagine this: What if we want to give our customers the ability to confirm their processing orders themselves? It’s simpler than you might think. Just by adding a “Confirm Order” button within My Account > Orders, customers can take control of the process with just a click.

Solution: Allow Customers to Complete a Processing Order in WooCommerce

add_filter( 'woocommerce_my_account_my_orders_actions', 'ts_confirm_order_my_account_orders_actions', 10, 2 );
   
function ts_confirm_order_my_account_orders_actions( $actions, $order ) {
    if ( $order->has_status( 'processing' ) ) {
        $actions['confirm-order'] = array(
            'url'  => wp_nonce_url( add_query_arg( array( 'confirm_order' => $order->get_id() ) ), 'woocommerce-confirm-order' ),
            'name' => __( 'Confirm Order', 'woocommerce' )
        );
    }
    return $actions;
}
   
add_action( 'template_redirect', 'ts_on_confirm_order_click_complete_order' );
    
function ts_on_confirm_order_click_complete_order( $order_id ) {
   if ( isset( $_GET['confirm_order'], $_GET['_wpnonce'] ) && is_user_logged_in() && wp_verify_nonce( wp_unslash( $_GET['_wpnonce'] ), 'woocommerce-confirm-order' ) ) {
        $order = wc_get_order( $_GET['confirm_order'] );
      $order->update_status( 'completed', 'Order confirmed by customer' );
    }
}

Output

The confirm order button is placed in the actions column of processing orders which will allow customers to confirm an order. Once the button is clicked, the order will be transitioned to completed status.


How to Allow Customers to Complete a Processing Order in WooCommerce? - Tyche Softwares


Along with giving customers the option to confirm the order, you can also add an ‘Order Again’ button in WooCommerce on My Account orders page. This will let the customer conveniently buy the product again if they want.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Share It:

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x