1

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>
mujuonly
  • 11,370
  • 5
  • 45
  • 75
Cray
  • 5,307
  • 11
  • 70
  • 166

2 Answers2

3
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";
}
mujuonly
  • 11,370
  • 5
  • 45
  • 75
  • Thanks, but I'm searching for a way without hiding the button with CSS. – Cray Apr 28 '20 at 18:31
  • that's great. Is there a way to change the link of the button. I guess there is a filter for that. See my edit in my question – Cray Apr 28 '20 at 18:44
1

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.

MrBi
  • 308
  • 1
  • 14