WooCommerce Order Again From My Account View Orders Endpoint

WooCommerce order again button showing in my account order view endpoint table

Pre-Requisites

There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About this Solution

This code allows the customer to reorder their previous orders from the View Orders endpoint on the My Account page. By default, the user must drill-down into the completed order to be able to reorder. This snippet adds a button to allow reordering from a higher level.

				
					/**
 *	Snippet Name:	WooCommerce Order Again From View Orders Endpoint
 *	Snippet Author:	ecommercehints.com
 */

add_filter( 'woocommerce_my_account_my_orders_actions', 'ecommercehints_order_again', 50, 2 );
function ecommercehints_order_again( $actions, $order ) {
    if ( $order->has_status( 'completed' ) ) { // Order Again button will only show for completed orders.
        $actions['order-again'] = array(
            'url'  => wp_nonce_url( add_query_arg( 'order_again', $order->id ) , 'woocommerce-order_again' ),
            'name' => __( 'Order Again', 'woocommerce' )
        );
    }
    return $actions;
}
				
			
WooCommerce Conversion Rate Optimisation (CRO) eBook
100 WooCommerce Conversion Rate Optimisation Tips

Leave a Reply

If you are going to write code in the comments, please wrap it between code tags.

Your email address will not be published. Required fields are marked *

Other Recent Guides

Subscribe To Emails

Get exclusive WooCommerce tips that I only share with email subscribers

Join hundreds of other subscribers