Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

204
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda