Skip to content

Instantly share code, notes, and snippets.

@zainaali
Created September 28, 2018 08:22
Show Gist options
  • Save zainaali/1ef31b38129941b598c760f110e783af to your computer and use it in GitHub Desktop.
Save zainaali/1ef31b38129941b598c760f110e783af to your computer and use it in GitHub Desktop.
Redirect page after order is placed based on order status Woocommerce
add_action( 'woocommerce_thankyou', 'bbloomer_redirectcustom');
function bbloomer_redirectcustom( $order_id ){
$order = new WC_Order( $order_id );
$url = 'https://siteurl/thank-you-payment/'; //Thank you page
$mem_url = 'https://siteurl/payment-denied/'; // denied page
if ( $order->status == 'pending' ) {
wp_redirect($mem_url);
}
else{
wp_redirect($url);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment