Support » Plugin: WooCommerce » remove 'Return To Shop' link on cart?

  • Dear WooCommerce team et al,

    Is there a way to completely disable (remove) the Return To Shop button link that shows up in the empty cart template linked below?

    https://github.com/woothemes/woocommerce/blob/master/templates/cart/cart-empty.php

    While I’ve come across many methods of changing the text and/or hyperlink that the woocommerce_return_to_shop_redirect filter calls, there doesn’t seem to be any successful attempt at removing the link completely from showing up, i.e. the below suggestions don’t seem to work at all:

    remove_filter( 'woocommerce_cart_is_empty', 'woocommerce_return_to_shop_redirect', 10 );
    remove_filter( 'woocommerce_cart_is_empty', 'woocommerce_return_to_shop_redirect', 10, 0 );
    remove_filter( 'woocommerce_cart_is_empty', 'woocommerce_return_to_shop_redirect', 10, 1 );
    remove_filter( 'woocommerce_return_to_shop_redirect', 'filter_woocommerce_return_to_shop_redirect', 10 );
    remove_filter( 'woocommerce_return_to_shop_redirect', 'filter_woocommerce_return_to_shop_redirect', 10, 0 );
    remove_filter( 'woocommerce_return_to_shop_redirect', 'filter_woocommerce_return_to_shop_redirect', 10, 1 );
    remove_action( 'woocommerce_cart_is_empty', 'action_woocommerce_cart_is_empty', 10 );
    remove_action( 'woocommerce_cart_is_empty', 'action_woocommerce_cart_is_empty', 10, 0 );
    remove_action( 'woocommerce_cart_is_empty', 'action_woocommerce_cart_is_empty', 10, 1 );

    I’m sure there is some combination that works properly perhaps with a different priority value or etc? Any advice much appreciated. Cheers!

    https://wordpress.org/plugins/woocommerce/

Viewing 9 replies - 1 through 9 (of 9 total)
  • hello,

    For this you have to copy the templates folder from woocommerce plugin to your child theme (or theme) folder, and rename it “woocommerce“.

    Then in your theme folder inside woocommerce > cart > open/edit the file cart-empty.php.
    Remove this:

    <p class="return-to-shop">
    	<a class="button wc-backward" href="<?php echo esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ); ?>">
    		<?php _e( 'Return To Shop', 'woocommerce' ) ?>
    	</a>
    </p>

    Save, it’s done.

    In your child theme, woocommerce folder is better to keep only the (folders and) files you are have edit.

    regards

    @lomars, thanks very much for your suggestion.

    However we do not use child themes (only custom themes, etc) and are hoping for a fix that involves WooCommerce hooks or something similar.

    If anyone knows the proper function do kindly share. Thanks!

    I can’t see a suitable hook.

    As @lomars, you could copy the cart-empty.php template to your custom theme, and edit the copy. You don’t have to have a child theme for the method to work. The copy goes here:
    wp-content/themes/my-custom-theme/woocommerce/cart/cart-empty.php

    A simpler and more sustainable way would be to allow the button to generate but hide it with some custom css:

    .return-to-shop {display:none}

    @lorro,

    Thanks for your input. We were hoping there was a hook of some sort but may have to resort to hiding it via CSS, although it’s a bit janky.

    Thanks for your help in any regard —

    Last Idea: JQUERY
    With Jquery targeting “.return-to-shop” class selector you can change/replace/delete html with what ever you want…

    Regards

    Plugin Support RK

    (@riaanknoetze)

    The following should help with that: https://www.skyverge.com/blog/change-woocommerce-return-to-shop-button/

    Instead of using return get_site_url(); you could just try return;

    @riaan
    yes you are right ! (Hope this will work)

    Thanks everyone. jQuery is a clever option however I’m not sure adding javascript into the mix is any “better” for cleanup/simplification/performance than simply using CSS to hide the element altogether? =\

    It does seem really strange that so many hooks are involved with such a simple feature and yet there is no way to disable it haha.

    Thanks for your time and input.

    An old topic, but wanted to add the CSS here in case anybody finds it like I did.

    .woocommerce-cart #top .button {
    display: none !important;
    }
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘remove 'Return To Shop' link on cart?’ is closed to new replies.