I'm creating a Woocommerce custom Payment Gateway plugin (it basically redirects the user to the payment service page and then the payment service page redirects the user back to an especified URL), everything is working as expected but I can't seem to create a custom thank-you page FROM THE PLUGIN.
What I mean with "from the plugin" is that if someone installs my Payment Gateway plugin they should be able to see the custom thank-you page without any aditional operation like adding a Woocommerce theme or page in WP.
Here is what I'm currently using to handle the default thank-you page:
The redirect URL is given by: $this->get_return_url($order))
The thank you page is hooked with:
add_action('woocommerce_thankyou_'.$this->id, array( $this, 'return_handler' ) );
And here is my function that should handle the thankyou page messages:
public function return_handler() {
$order_id = get_query_var('order-received');
global $woocommerce;
$order = new WC_Order( $order_id );
//NEXT I JUST CHECK THE ORDER AND SHOW MESSAGES DEPENDING ON THE RESULT
}
EDIT: also if there is another way of returning the user to an URL that will trigger one of my plugins function, that could be a valid option.
I think the filter you need to target is
woocommerce_payment_successful_result
which is in theWC_Checkout
class.I haven't tested this, so use at your own risk.