New Landing How can we help? Themeforest Theme Support Neighborhood Can I change the order complete landing page after PayPal order complete

Viewing 12 posts - 1 through 12 (of 12 total)
  • #198311
    pkd-web22
    Member
    Post count: 23

    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

    #198329
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Hi,

    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

    #198460
    pkd-web22
    Member
    Post count: 23

    Hi 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

    #198482
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    You need to insert this code at functions.php of child theme.
    Thanks
    Mohammad

    #198506
    pkd-web22
    Member
    Post count: 23

    Hi,

    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

    #198509
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Hi,

    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

    #198516
    pkd-web22
    Member
    Post count: 23

    As 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

    #198521
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    don’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

    #198567
    pkd-web22
    Member
    Post count: 23

    Hi,

    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

    #198698
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Hi,

    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

    #198711
    pkd-web22
    Member
    Post count: 23

    Great thanks – worked a treat Rui 😉

    #198730
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Nice. Glad I could help.
    -Rui

Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register