Last active
June 14, 2017 01:43
-
-
Save woogist/5f954c78c66266721321 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
add_action( 'template_redirect', 'wc_custom_redirect_after_purchase' ); | |
function wc_custom_redirect_after_purchase() { | |
global $wp; | |
if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) { | |
$order_id = absint( $wp->query_vars['order-received'] ); | |
$order_key = wc_clean( $_GET['key'] ); | |
$redirect = get_permalink( {PAGE_ID} ); | |
$redirect .= get_option( 'permalink_structure' ) === '' ? '&' : '?'; | |
$redirect .= 'order=' . $order_id . '&key=' . $order_key; | |
wp_redirect( $redirect ); | |
exit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment