Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
00 Days
00 Hours
00 Minutes
00 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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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' );
}
}
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' ); } }
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
Newest
Oldest
Inline Feedbacks
View all comments
huo
7 months ago

How can I place this button on the “My Account” > “Orders” > “View Orders” page?

huo
7 months ago
Reply to  Saranya

Thank you very much for your code. I can test both ends of the code and it works independently. However, when I want it to be displayed on My Account > Orders and View Order page at the same time, it does not work properly and the website will display a white screen.

huo
7 months ago
Reply to  Saranya

Thanks again for your reply I entered the code into big data and it said there was an error and gave me an answer like this, and I ran it fine. // Added "Confirm Order" button to the My Account Orders list add_filter( 'woocommerce_my_account_my_orders_actions', 'ts_add_confirm_order_button_to_my_orders', 10, 2 ); function ts_add_confirm_order_button_to_my_orders( $actions, $order ) {     if ( $order->has_status( 'processing' ) ) {         $actions['confirm-order'] = array(             'url'  => wp_nonce_url( add_query_arg( array( 'confirm_order' => $order->get_id() ), wc_get_page_permalink( 'myaccount' ) ), 'woocommerce-confirm-order' ),             'name' => __(… Read more »

reCaptcha Error: grecaptcha is not defined
0
Would love your thoughts, please comment.x
()
x
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible.

Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

By using our site, you acknowledge that you have read and understood our Privacy Policy and Terms & Conditions.