Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

210
Views
Woocommerce - add order again on thankyou page

I'm trying to put the Order Again button on thankyou page but it doesn't work, what did I do wrong?

My code on thankyou page

<?php echo esc_url( $order_again_url ); ?>

In my function.php I'm using

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;
}
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Reorder only allow with order status -> completed. If you want to reorder on thankyou page so first you should allow status for reorder with on-hold, pending, processing etc.. like this:

add_filter( 'woocommerce_valid_order_statuses_for_order_again', 'allowed_order_again_status', 10, 1);
function allowed_order_again_status($array){
    $array = array_merge($array, array('on-hold','pending', 'processing', 'completed'));
    return $array;
}

Then add reorder button by using woocommerce_thankyou hooks like this:

add_filter( 'woocommerce_thankyou', 're_order_woocommerce_thankyou', 4 );
function re_order_woocommerce_thankyou($order_id) {
    $order = wc_get_order($order_id);
    if ( $order->has_status( 'completed' ) || $order->has_status( 'processing' ) || $order->has_status( 'pending' ) || $order->has_status( 'on-hold' ) ) {
        $actions['order-again'] = array(
            'url'  => wp_nonce_url( add_query_arg( 'order_again', $order->id ) , 'woocommerce-order_again' ),
            'name' => __( 'Order Again', 'woocommerce' )
        ); 
        ?>
        <a class="btn btn-primary" href="<?php echo $actions['order-again']['url'];?>" ><?php echo $actions['order-again']['name'];?> </a>
        <?php 
        return $order_id;
    }
}

Note: Reorder button will be visible on buttom of page but If you want Reorder button on any position on thankyou page then you shoult override thankyou page just copy from woocommerce plugin and past inside you active theme -> woocommerce -> thankyou.php and add reorder button accordingly

over 4 years ago · Santiago Trujillo Report

0

Reorder button/link for my account page -> order tab like this:

add_filter( 'woocommerce_valid_order_statuses_for_order_again', 'allowed_order_again_status', 10, 1);
function allowed_order_again_status($array){
    $array = array_merge($array, array('on-hold','pending', 'processing', 'completed'));
    return $array;
}

add_filter( 'woocommerce_my_account_my_orders_actions', 'woo_order_again_from_myaccount', 50, 2 );
function woo_order_again_from_myaccount( $actions, $order ) {
    if ( $order->has_status( 'completed' ) || $order->has_status( 'processing' ) || $order->has_status( 'pending' ) || $order->has_status( 'on-hold' ) ) {
        $actions['order-again'] = array(
            'url'  => wp_nonce_url( add_query_arg( 'order_again', $order->id ) , 'woocommerce-order_again' ),
            'name' => __( 'Order Again', 'woocommerce' )
        );
    }

    return $actions;
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!