My Account

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

100 WooCommerce Conversion Rate Optimisation Tips

This field is for validation purposes and should be left unchanged.

Let’s collaborate!

Need to outsource WordPress development?

Join forces with UnlimitedWP for an outsourced white label web development service you can truly rely on.

First Timer Here?

Sign up to receive 20% off on your first month with us.

26027
WELCOME OFFER