Answer the question
In order to leave comments, you need to log in
How to redirect woocommerce with order-pay?
When trying to pay through the payment system, it sends to the order_pay page.
The link looks like this:
../checkout/order-pay/9762/?pay_for_order=true&key=wc_order_SWO6Y0Nj66YNA
There are a lot of solutions on the Internet, how to redirect to an arbitrary page, one of the proven and working solutions
add_action( 'template_redirect', 'thankyou_custom_payment_redirect');
function thankyou_custom_payment_redirect(){
if ( is_wc_endpoint_url( 'order-received' ) ) {
global $wp;
// Get the order ID
$order_id = intval( str_replace( 'checkout/order-received/', '', $wp->request ) );
// Get an instance of the WC_Order object
$order = wc_get_order( $order_id );
// Set HERE your Payment Gateway ID
if( $order->get_payment_method() == 'cheque' ){
// Set HERE your custom URL path
wp_redirect( home_url( '/custom-page/' ) );
exit(); // always exit
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question