Created
April 20, 2023 18:15
-
-
Save finalwebsites/b3f412b820d8132efc3dce9575e2c5b1 to your computer and use it in GitHub Desktop.
WooCommerce: Redirect the customer to your own thank you page (one for successful payments and one for all other statuses)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'woocommerce_thankyou', 'fw_redirect_custom_thank_you_page'); | |
function fw_redirect_custom_thank_you_page( $order_id ){ | |
$order = wc_get_order( $order_id ); | |
$url = home_url('/YOUR_THANK_YOU_PAGE/'); // <<< change this slug | |
if ( $order->has_status( array('processing', 'completed' ) ) ) { | |
wp_safe_redirect( $url ); | |
exit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Place this code into the functions.php file from your WordPress child theme