Skip to content

Instantly share code, notes, and snippets.

@woogist
Created July 28, 2015 06:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save woogist/7f3ed335a45182247088 to your computer and use it in GitHub Desktop.
Save woogist/7f3ed335a45182247088 to your computer and use it in GitHub Desktop.
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'] );
/**
* Replace {PAGE_ID} with the ID of your page
*/
$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