Redirect to custom page after complete order-WooCommerce

How to redirect customers to a custom landing page after the order process?

Some of them need specific page redirection after the order process to achieve more sales. Below code will help you to find solution.

/**
 * @snippet       Redirect to custom page after complete order – WooCommerce
 */
  
add_action( 'woocommerce_thankyou', 'mycode_redirect');
  
function mycode_redirect( $order_id ){
    $order = wc_get_order( $order_id );
    $url = 'https://codeamend.com/thank-you';
    if ( ! $order->has_status( 'failed' ) ) {
        wp_safe_redirect( $url );
        exit;
    }
}

Thank You.

Redirect to Custom Thank you Page – WooCommerce, Redirect to custom page after complete order – WooCommerce, thank you page redirection
About author
Kaviya Manoharan
Kaviya Manoharan
PHP and Wordpress Developer
0 comments
Be a First Comment
Add Your Comment