Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
WooCommerce - Add Order Again button to My Orders actions
* Add order again button in my orders actions.
* @param array $actions
* @param WC_Order $order
* @return array
function cs_add_order_again_to_my_orders_actions( $actions, $order ) {
if ( $order->has_status( 'completed' ) ) {
$actions['order-again'] = array(
'url' => wp_nonce_url( add_query_arg( 'order_again', $order->id ) , 'woocommerce-order_again' ),
'name' => __( 'Order Again', 'woocommerce' )
return $actions;
add_filter( 'woocommerce_my_account_my_orders_actions', 'cs_add_order_again_to_my_orders_actions', 50, 2 );
Copy link

r0ks0n commented May 1, 2020


Is there any way to skip cart page with this code and redirect user to checkout?

Copy link

Alexio454 commented Nov 23, 2020

It would be better to also have the button on orders page next to view my order button. It's kind of getting lost where it's placed.
Do you think you could do that?

Copy link

Nyconing commented Mar 25, 2022

Use this to declare which statuses can have order again button.

add_filter( 'woocommerce_valid_order_statuses_for_order_again', 'add_order_again_status', 10, 1);
function add_order_again_status($array){
    $array = array_merge($array, array('on-hold', 'processing', 'pending-payment', 'cancelled', 'refunded'));
    return $array;

Copy link

neemassree commented Jun 4, 2022

Hi all,
I have added this code to my functions.php. It works on orders with the status 'completed'. But I need to add this function to orders with status 'processing' also. So I added the below lines. But the link to which the button redirect shows the cart is empty. Could anyone help me, please?

elseif ( $order->has_status( 'processing') ) {
$actions['order-again'] = array(
'url' => wp_nonce_url( add_query_arg( 'order_again', $order->id ) , 'woocommerce-order_again' ),
'name' => __( 'Order Again', 'woocommerce' )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment