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.
Adding the Confirm Order Button to My account > view Order page in WooCommerce
The below updated code will allow you to place the confirm order button directly on the Woocommerce my account view orders page. In the modified code we have used the filter ‘woocommerce_order_details_after_order_table’ action hook and the wc_get_endpoint_url() function, explicitly pointing to the current order’s View Order page. By placing the button only on the View Order page, customers can review order details such as items purchased, shipping address, and payment method and then confirm the order.
add_action( 'woocommerce_order_details_after_order_table', 'ts_confirm_order_my_account_orders_actions' ); function ts_confirm_order_my_account_orders_actions( $order ) { if ( $order->has_status( 'processing' ) ) { $url = wp_nonce_url( add_query_arg( array( 'confirm_order' => $order->get_id() ), wc_get_endpoint_url( 'view-order', $order->get_id(), wc_get_page_permalink( 'myaccount' ) ) ), 'woocommerce-confirm-order' ); echo '<a href="' . esc_url( $url ) . '" class="button confirm-order-button">' . __( 'Confirm Order', 'woocommerce' ) . '</a>'; } }
The ouput image below ensures that the button is specifically added after the order details table on the View Order page.
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.
How can I place this button on the “My Account” > “Orders” > “View Orders” page?
Hi Huo,

To place the button on the My Account > Orders > View Orders page, we’ve made some tweaks to the original code. You can find the updated code snippet below the heading: “Adding the Confirm Order Button to My Account > View Order Page in WooCommerce”
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.
To meet your requirement of displaying the “Confirm Order” button on both the My Account > Orders page and the My Account > View Order page, you’ll need to use a combination of the code for both pages. Finally, add the order confirmation logic code as shown in this screenshot-https://prnt.sc/RfCz2VcTVHJC
While the combined code works fine on my setup when tested together, I’m unsure why it isn’t working on your site. It could be due to factors like theme or plugin conflicts, or any additional customizations made to your site.
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 »