Digital experiences for all disciplines
New Landing › How can we help? › Themeforest Theme Support › Neighborhood › Can I change the order complete landing page after PayPal order complete
New Landing › How can we help? › Themeforest Theme Support › Neighborhood › Can I change the order complete landing page after PayPal order complete
- This topic has 11 replies, 3 voices, and was last updated 9 years by Rui Guerreiro – SUPPORT.
-
Posted in: Neighborhood
-
July 27, 2015 at 9:57 pm #198311
Hi,
Is it possible to specify a different post order completion ‘landing page’ (so not the default My Account page) once the user has completed Paypal and is redirected back to the website.
It’s just that my client wants all orders as ‘guest’ orders and doesn’t want it obvious that there’s a ‘My account’ page – which is what they see on order completion along with a Thank you message.
Any help on where or how I can change this in WooCommerce/Theme would be great.
Thanks
July 27, 2015 at 11:51 pm #198329Hi,
I found the code below to enable to redirect to a specific page after purchasing.
add_action( 'template_redirect', 'wc_custom_redirect_after_purchase' ); function wc_custom_redirect_after_purchase() { global $wp; if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) { wp_redirect( 'http://www.yoururl.com/your-page/' ); exit; } }
-Rui
July 28, 2015 at 9:26 am #198460Hi Rui,
Does that involve adding or changing some .php file somewhere? As I’m not that technical and generally keep within the theme Options parameters?
Is there no other way within the CMS to do this?
Thanks
July 28, 2015 at 10:18 am #198482Hi,
You need to insert this code at functions.php of child theme.
Thanks
MohammadJuly 28, 2015 at 11:25 am #198506Hi,
I presume that if I’ve not used a child theme (as I wasn’t intending to change any core files – and don’t really know how to) that if I change the functions.php file I’ll need to update it every time I do a theme update as it’ll be over written?
Thanks
July 28, 2015 at 11:32 am #198509Hi,
Apologize I placed the code and forgot to explain you.
You definitely should use a child theme, there’s no point of placing that in the parent theme because it will only cause problems and more work for you.
You just have to install the child theme that is inside the zip from Themeforest, and activate it.
Then copy the code I placed above to the functions.php.
If you are not comfortable with that let me know and provide admin access.
-Rui
July 28, 2015 at 11:42 am #198516As my site hasn’t used a child theme will all the theme options changes I have made within the CMS and content added, pages created, inc. custom css added be wiped out if I then use a child theme?
And does the child theme have to be updated very time along with the main theme?
Thanks
July 28, 2015 at 11:59 am #198521don’t worry it won’t affect anything it only extends the Parent theme functionality.
When the child theme is empty everything works like without having the child theme, but when you need to add a function to modify something in this case the redirection after the order is complete, this is the way it should be do it that’s why exist this concept so it can be possible to extend themes without modifying the core files.
https://codex.wordpress.org/Child_Themes
-Rui
July 28, 2015 at 2:09 pm #198567Hi,
I’ve now installed the child theme but it only has a style.css file and no functions.php file what do I need to ‘add’ to the new functions.php file (in addition to the code previously mentioned by Rui) to get it to work? WordPress gives some clues but I can’t work out if Neighborhood has one or multiple stylesheets or something as the start bit in the functions.php file needs to know this?
Thanks
July 28, 2015 at 7:19 pm #198698Hi,
Since it’s an empty child theme create a new file called functions.php and the entire code should be this one.
<?php add_action( 'template_redirect', 'wc_custom_redirect_after_purchase' ); function wc_custom_redirect_after_purchase() { global $wp; if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) { wp_redirect( 'http://www.yoururl.com/your-page/' ); exit; } } ?>
-Rui
July 28, 2015 at 8:34 pm #198711Great thanks – worked a treat Rui 😉
July 28, 2015 at 9:52 pm #198730Nice. Glad I could help.
-Rui -
Posted in: Neighborhood
You must be logged in and have valid license to reply to this topic.