Menu Close

Redirect to custom page after complete order-WooCommerce

0
(0)

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;
    }
} 

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Share

Posted in PHP, WooCommerce, WordPress

Leave a Reply

Your email address will not be published. Required fields are marked *

You can also read...