I would like to start by saying im not developer my self at all, but im trying to come up with a solution my self. Im trying to override the woocommerce_get_cancel_order_url_raw taht is inside public_html/wp-content/plugins/woocommerce/includes/class-wc-order.php from the functions.php file of the template so it does not get overriden when updating plugins. I want to be able to define a url (in this case the home page, but maybe it is important to mention im using WPML so there are more than one lang, but if it is too complicated, there is a redirection in place based on the user geolocation). I found this function, but seem not to be working or at least i cant make it work:
add_filter( 'woocommerce_get_cancel_order_url_raw', 'paypal_canceled_redirect' );
function paypal_canceled_redirect(){
wp_redirect(home_url()); // REDIRECT PATH
exit;
}
Thanks
Kind regards
2
Answers
Thanks to @CBroe, he pointed me into the right direction, and more over helped me implementing the solution. This would be:
The purpose of the
woocommerce_get_cancel_order_url_raw
filter is to modify that URL in string form. Directly callingwp_redirect
in there makes no sense. (This is a value that gets passed to the external payment gateway service, so that the gateway can redirect the user back to your site if they cancel the process.)You need to return the new URL value from this function.