Last active
April 4, 2023 05:48
-
-
Save Acephalia/8dd50d8129efa3df5ae3dd6447f87de2 to your computer and use it in GitHub Desktop.
Redirect to Seperate Thank You Page For 2 or More Items
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
Use snippet wcrtpf2omi2.php if you don't want the snippet to handle redirection for single products. Replace the $thankyou_page_url and $thankyou_multiple_page_url variables with the URLs of your custom thank you pages as needed. |
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
function custom_thankyou_redirection() { | |
global $woocommerce; | |
$items_count = $woocommerce->cart->cart_contents_count; | |
$thankyou_page_url = 'https://www.yourwebsite.com/thank-you/'; | |
$thankyou_multiple_page_url = 'https://www.yourwebsite.com/thank-you-multiple/'; | |
if ( $items_count >= 2 ) { | |
wp_redirect( $thankyou_multiple_page_url ); | |
exit; | |
} else { | |
wp_redirect( $thankyou_page_url ); | |
exit; | |
} | |
} | |
add_action( 'woocommerce_thankyou', 'custom_thankyou_redirection' ); |
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
function custom_thankyou_redirection() { | |
global $woocommerce; | |
$items_count = $woocommerce->cart->cart_contents_count; | |
if ( $items_count >= 2 ) { | |
$thankyou_multiple_page_url = 'https://www.yourwebsite.com/thank-you-multiple/'; | |
wp_redirect( $thankyou_multiple_page_url ); | |
exit; | |
} | |
} | |
add_action( 'woocommerce_thankyou', 'custom_thankyou_redirection' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment