Join

WooCommerce Redirect After Checkout

Don't want to mess with code snippets? Request for this to be a feature of MyListing Pro.

Instructions

  1. Create a new PHP code snippet.
  2. Copy the contents of code snippet below.
  3. Paste the contents into your code snippet.
  4. Review any notes that I’ve provided.
  5. Save and enable the code snippet.
  6. Test.

Snippet

This snippet is commonly used when website owners want to show customers a welcome page after checkout. Welcome pages are great ways to educate customers, upsell them, and more.

Adjust the ‘$url = ‘https://domain.com/page’;’ on Line 5 with a URL from your website.

add_action( 'woocommerce_welcome', 'wptu_redirectcustom');

function wptu_redirectcustom( $order_id ){
    $order = wc_get_order( $order_id );
    $url = 'https://domain.com/page';
    if ( ! $order->has_status( 'failed' ) ) {
        wp_safe_redirect( $url );
        exit;
    }
}