WooCommerce 订阅:删除我的帐户页面上的 "Browse products" 按钮
WooCommerce Subscriptions: Remove "Browse products" button on my account page
我想删除我的帐户区订阅页面上的"Browse Products"按钮。
我在模板文件 my-subscriptions.php
中找到了输出。
但是没有过滤器可以在不编辑模板文件的情况下将其删除。
还有其他方法吗?
也许有办法更改按钮的 link(针对特定产品)和文本?
这是 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>
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 );
要更改 link,请使用以下代码。
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 隐藏只是隐藏所有消息框,所以不知道这对您或其他人是否有用。
我想删除我的帐户区订阅页面上的"Browse Products"按钮。
我在模板文件 my-subscriptions.php
中找到了输出。
但是没有过滤器可以在不编辑模板文件的情况下将其删除。
还有其他方法吗? 也许有办法更改按钮的 link(针对特定产品)和文本?
这是 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>
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 );
要更改 link,请使用以下代码。
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 隐藏只是隐藏所有消息框,所以不知道这对您或其他人是否有用。