• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

155
Vistas
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;
}
about 3 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

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

about 3 years ago · Santiago Trujillo Denunciar

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;
}
about 3 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda