Menu Close

Redirect to custom page after complete order-WooCommerce

Codeamend

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.

PHP Code

/**
 * @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;
    }
} 
Posted in PHP, WooCommerce, WordPress

You can also read...