Hot Line:

+1 (917) 730-2010

AI-Powered Web Development, SEO, Shopify & WordPress — Get a Free Consultation Today. Get Started

Tutorials

How To Add WooCommerce Redirect After Checkout

  • 31 May, 2023
  • 0 Comments
  • By WebSensePro
How To Add WooCommerce Redirect After Checkout

As a WooCommerce store owner, you may want to enhance the post-checkout experience for your customers by adding a redirect to a specific page. In this blog post, we will guide you through the process of creating a child theme using an online child theme generator and adding custom code to implement a WooCommerce redirect after checkout. By following these steps, you can easily customize your online store’s checkout process and provide a seamless user experience.

Step 1: Generate A Child Theme

Generate a Child Theme To begin, navigate to https://childtheme-generator.com online child theme generator that simplifies the process of creating a child theme. Enter your parent theme’s name and details, such as the theme author, version, and website. Customize the options as needed, and click on the “Create Child Theme” button.

Step 2: Access the Child Theme’s Functions.php File

After uploading the child theme, log in to your WordPress dashboard and navigate to “Appearance” > “Theme Editor.” On the right-hand side, you will see a list of theme files. Locate and select the functions.php file of your child theme. This is where you will add the custom code.

add_action( 'woocommerce_thankyou', 'websensepro_redirectcustom');
function websensepro_redirectcustom( $order_id ){
    $order = wc_get_order( $order_id );
    $url = 'https://websensepro.com/';
    if ( ! $order->has_status( 'failed' ) ) {
        wp_safe_redirect( $url );
        exit;
    }
}

Make sure to replace ‘https://websensepro.com/‘ with the actual URL of the page you want to redirect your customers to.

5/5 · 4 votes
Tags:

    Comments

    Background Pattern

    Want to work with us?

    Let’s build your website, grow your traffic, and automate your business with AI.

    Background Pattern