skip to Main Content

WordPress Code Snippets


Redirect to Custom Thank You Page after WooCommerce Payment

This snippet enhances the post-purchase experience by directing customers to a tailored thank you page.

add_action('woocommerce_thankyou', 'redirect_after_payment');
function redirect_after_payment($order_id) {
    $order = wc_get_order($order_id);
    if ($order->get_status() === 'completed') {
        wp_redirect('https://yourdomain.com/thank-you'); // Custom thank you page URL
        exit;
    }
}



I’m a WordPress developer with 10+ years of experience in WooCommerce and custom plugins. I combine technical expertise with design flair to help you create standout, user-friendly websites. Let’s transform your digital presence!

Best WordPress Hosting
Back To Top
Search