skip to Main Content

I want to remove the “Browse Products” button on the subscription page of My account area.

I found the output in the template file my-subscriptions.php.
But there is no filter to remove it without editing the template file.

Is there any other way to do that?
Maybe there is a way to change the link of the button (to a specific product) and the text?

This is the code for the link:

<a class="woocommerce-Button button" href="<?php echo esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ); ?>">
    <?php esc_html_e( 'Browse products', 'woocommerce-subscriptions' ); ?>
</a>

2

Answers


  1. add_action( 'wp_head', 'hide_browse_product_element', 100 );
    
    function hide_browse_product_element() {
        echo "<style> .no_subscriptions{display:none;} </style>";
    }
    

    Try this code snippet

    If you want to change the text without overriding the template, try this

    function change_browse_product_element( $translated_text, $text, $domain ) {
        switch ( $translated_text ) {
            case 'Browse products' :
                $translated_text = __( 'My Button Text', 'woocommerce' );
                break;
        }
        return $translated_text;
    }
    
    add_filter( 'gettext', 'change_browse_product_element', 20, 3 );
    

    From here

    For changing the link, please use below code.

    add_filter( 'woocommerce_return_to_shop_redirect', 'mujuonly_rediect_browse_product' );
    
    function mujuonly_rediect_browse_product( $url ) {
        return "https://www.google.com";
    }
    
    Login or Signup to reply.
  2. You can hide with css:

    div.woocommerce-Message.woocommerce-Message--info.woocommerce-info 
    a.woocommerce-Button.button
    {
    
     visibility: hidden !important;
    }
    

    Anyway hide with css just hide all message box, so no idea if this will be useful for you or somebody.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search