簡體   English   中英

WooCommerce 訂閱:刪除我的帳戶頁面上的“瀏覽產品”按鈕

[英]WooCommerce Subscriptions: Remove “Browse products” button on my account page

我想刪除我的帳戶區域訂閱頁面上的“瀏覽產品”按鈕。

我在模板文件my-subscriptions.php中找到了 output 。 但是沒有過濾器可以在不編輯模板文件的情況下將其刪除。

有沒有其他方法可以做到這一點? 也許有一種方法可以更改按鈕的鏈接(特定產品)和文本?

這是鏈接的代碼:

<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>
add_action( 'wp_head', 'hide_browse_product_element', 100 );

function hide_browse_product_element() {
    echo "<style> .no_subscriptions{display:none;} </style>";
}

試試這個代碼片段

如果你想在不覆蓋模板的情況下更改文本,試試這個

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 );

從這里

要更改鏈接,請使用以下代碼。

add_filter( 'woocommerce_return_to_shop_redirect', 'mujuonly_rediect_browse_product' );

function mujuonly_rediect_browse_product( $url ) {
    return "https://www.google.com";
}

您可以使用 css 隱藏:

div.woocommerce-Message.woocommerce-Message--info.woocommerce-info 
a.woocommerce-Button.button
{

 visibility: hidden !important;
}

無論如何隱藏 css 只是隱藏所有消息框,所以不知道這是否對您或某人有用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM