Change the redirect of the WooCommerce «back to store» button

This topic has 12 replies, 3 voices, and was last updated 3 years, 8 months ago ago by Robert Hall

  • Avatar: Elgaroe
    Elgaroe
    Participant
    March 27, 2021 at 17:41

    Hi, I have a specific page for my store that is not the default woocomerce, I would like to be able to link to that page when I click the return to store button, I have been looking online and I have found a code that has worked for me in others web but not in this one.
    the code is the following.
    / **
    * Changes the redirect URL for the Return To Shop button in the cart.
    *
    * @return string
    * /
    function wc_empty_cart_redirect_url () {
    return ‘https://www.cuentosenlacabeza.com/nuestra-libreria/’;
    }
    add_filter (‘woocommerce_return_to_shop_redirect’, ‘wc_empty_cart_redirect_url’);

    I have put it in the functions.php of my child theme.
    If you could help me

    11 Answers
    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    March 28, 2021 at 06:22

    Hi,

    Copy
    xstore/woocommerce/cart/cart-empty.php to xstore-child/woocommerce/cart/cart-empty.php,
    xstore/woocommerce/cart/cart.php to xstore-child/woocommerce/cart/cart.php,
    xstore/woocommerce/loop/no-products-found.php to xstore-child/woocommerce/loop/no-products-found.php and replace Return To Shop with link you need https://developer.wordpress.org/reference/functions/home_url/ .

    Regards

    Avatar: Elgaroe
    Elgaroe
    Participant
    March 28, 2021 at 09:54

    Hello I have copied the codes but I don’t know how to add the url to the last code, I don’t know where I should add my custom url https://www.cuentosenlacabeza.com/nuestra-libreria/
    if you could help me thanks
    this is the code where retum to shop appears

    <?php esc_html_e('Check your spelling or search again with less specific terms.', 'xstore') ?>
    
    	<a class="btn black medium" href="<?php echo get_permalink(wc_get_page_id('shop')); ?>"><span><?php esc_html_e('Return To Shop', 'xstore') ?></span></a>
    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    March 28, 2021 at 14:46

    Hello,

    Just add the link like here – http://prntscr.com/10y4g2k
    <p><a class="btn black" href="https://www.cuentosenlacabeza.com/nuestra-libreria/"><span><?php esc_html_e('Return To Shop', 'xstore') ?></span></a></p>

    Regards

    Avatar: Elgaroe
    Elgaroe
    Participant
    March 28, 2021 at 16:12

    it still doesn’t work if they could check it on the web please. Thanks

    Please contact administrator
    for this information.
    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    March 29, 2021 at 06:24

    Hello,

    It looks like you have changed wp-admin access http://prntscr.com/10yq1ju
    .php files should be edited via FTP, not Dashboard.
    Additional customization in files is outside the scope of our basic support.

    Regards

    Avatar: Elgaroe
    Elgaroe
    Participant
    March 29, 2021 at 10:03

    Good morning the files I am editing them from the file manager of my accommodation, I attach an image, but it still does not work, it continues to lead to the default woocomerce page.
    https://www.dropbox.com/s/fectvs03uqpkvuh/imagen.jpg?dl=0

    Please contact administrator
    for this information.
    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    March 29, 2021 at 12:49

    Hello,

    It looks like you provided a wrong screenshot.
    As I can see, your changes work here – http://prntscr.com/10yygg2 and http://prntscr.com/10yyhg7 Clear cache and check. About this link – http://prntscr.com/10yyllu , you did not change it in xstore-child/woocommerce/cart/cart.php.
    About the link here – http://prntscr.com/10yyole , re-write etheme_get_mini_cart_empty function (xstore/framework/woo.php file) via functions.php file of the child theme.

    Regards

    Avatar: Elgaroe
    Elgaroe
    Participant
    March 29, 2021 at 13:39

    About the link here: http://prntscr.com/10yyole, rewrite the etheme_get_mini_cart_empty function (xstore / framework / woo.php file) through the functions.php file of the child theme.
    I do not understand this part what should I do? If you could tell me a little more detailed the steps please.

    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    March 29, 2021 at 16:13

    Read this article – https://developer.wordpress.org/themes/advanced-topics/child-themes/#using-functions-php
    Just add the next code in functions.php of your child theme:

    if ( ! function_exists( 'etheme_get_mini_cart_empty' ) ) {
    	function etheme_get_mini_cart_empty(){
    		?>
            <div class="woocommerce-mini-cart__empty-message empty">
                <p><?php esc_html_e( 'No products in the cart.', 'xstore' ); ?></p>
    			<?php if ( wc_get_page_id( 'shop' ) > 0 ) : ?>
                    <a class="btn" href="https://www.cuentosenlacabeza.com/nuestra-libreria/"><span><?php esc_html_e('Return To Shop', 'xstore') ?></span></a>
    			<?php endif; ?>
            </div>
    		<?php
    	}
    }

    Regards

    Avatar: Elgaroe
    Elgaroe
    Participant
    March 29, 2021 at 17:04

    great now if it works thanks

    Avatar: Robert Hall
    Robert Hall
    Support staff
    March 29, 2021 at 19:37

    Hello

    Thank you so much for your kind words.

    If you have any other issue in this theme package let us know we are always here to provide you customer support.

    Robert Hall

  • Viewing 12 results - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.