Skip to content
Advertisement

Custom conditional redirections after WooCommerce checkout payment

I use Lirox One theme on WordPress with WooCommerce. I want make custom redirections after payment:
If a customer buy product ID 333, It will be redirected to product 444 (for example).

I have make some custom code but it doesn’t works, I get an error 500 (and debug is empty).

What I am doing wrong and how can I make it work?

This is my code:

JavaScript

Advertisement

Answer

For redirections, use a custom function hooked in WordPress template_redirect action hook,
to avoid errors 500…

I have changed your code as you will see, to match your requirements. This code is made for WooCommerce version 3+:

JavaScript

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

Code is tested and works on WC 3+

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement