Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #998997

    I am using a different page for my shop and want to change the href for the “return to shop” button that comes with woocommerce. Is this something I can do within the enfold theme?
    Thanks!

    #998999

    Hey kpcradix!

    Use this code to change the back to shop cart url:

    
    
    /**
     * Changes the redirect URL for the Return To Shop button in the cart.
     *
     * @return string
     */
    function wc_empty_cart_redirect_url() {
    	return 'http://mywebsite.com/sample-page/';
    }
    add_filter( 'woocommerce_return_to_shop_redirect', 'wc_empty_cart_redirect_url' );
    
    

    and replace http://mywebsite.com/sample-page/ with the url of the page you want to redirect to.

    You can insert it into the functions.php of your child theme. If you don’t use a child theme I’d recommend to create a small plugin, otherwise the code will be removed on every theme update.

    You can use this code for the plugin:

    
    
    <?php
    /*
    Plugin Name: Enfold Custom Code
    Description: Enfold Custom Code
    Version:     1.0
    Author:      InoPlugs
    Plugin URI:  https://inoplugs.com
    Author URI:  https://inoplugs.com
    */
    
    /**
     * Changes the redirect URL for the Return To Shop button in the cart.
     *
     * @return string
     */
    function wc_empty_cart_redirect_url() {
    	return 'http://mywebsite.com/sample-page/';
    }
    add_filter( 'woocommerce_return_to_shop_redirect', 'wc_empty_cart_redirect_url' );
    

    – replace http://mywebsite.com/sample-page/, then save it to a text file with the extension .php (i.e. enfold_custom_code.php).

    Then upload this text fiele to wp-content/plugins/. Afterwards go to the wordpress admin panel > Plugins and activate the new plugin.

    Best regards,
    Peter

    #999002

    Peter you are awesome! .. but I’ve never created a plug-in before and I’m not familiar with php. I will give it a try though and get back if I have any trouble with your instructions.
    Thanks!!

    #999005

    Hi,

    Ok, I’ll leave this thread open.

    Best regards,
    Dude

    #999201

    The instructions to create a plug-in worked like a charm. Thanks again Peter!!

    #999209

    Hi,

    Great, glad I could help you :)

    Best regards,
    Dude

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Change link for "return to shop" button in woocommerce cart’ is closed to new replies.