【发布时间】:2016-09-04 17:32:44
【问题描述】:
我想从结帐页面顶部删除“xx 产品已添加到您的购物车”消息。
我该怎么做?
有人提出了建议(下面的链接),但对我没有用。
Remove/Hide Woocommerce Added to Cart Message but Keep/Display Coupon Applied Message
【问题讨论】:
标签: php css wordpress woocommerce checkout
我想从结帐页面顶部删除“xx 产品已添加到您的购物车”消息。
我该怎么做?
有人提出了建议(下面的链接),但对我没有用。
Remove/Hide Woocommerce Added to Cart Message but Keep/Display Coupon Applied Message
【问题讨论】:
标签: php css wordpress woocommerce checkout
Woocommerce 3+ 更新
钩子wc_add_to_cart_message 已弃用并由wc_add_to_cart_message_html 取代。您可以使用以下(紧凑有效的方式):
add_filter( 'wc_add_to_cart_message_html', '__return_false' );
或者正常方式:
add_filter( 'wc_add_to_cart_message_html', 'empty_wc_add_to_cart_message');
function empty_wc_add_to_cart_message( $message, $products ) {
return '';
};
在 Woocommerce 3 之前,使用这个:
仅删除消息(将其粘贴到活动子主题或主题内的function.php 文件中)。此函数将返回一个空消息:
add_filter( 'wc_add_to_cart_message', 'empty_wc_add_to_cart_message', 10, 2 );
function empty_wc_add_to_cart_message( $message, $product_id ) {
return '';
};
代码进入您的活动子主题(或活动主题)的 function.php 文件中。
注意:wc_add_to_cart_message 替换已弃用的钩子 woocommerce_add_to_cart_message。
(已更新)
CSS:删除结帐页面上的顶部消息框 (将此 CSS 规则添加到位于活动子主题或主题内的 style.css 文件):
.woocommerce-checkout .woocommerce .woocommerce-message {
display:none !important;
}
【讨论】:
functions.php)。
您必须使用此代码才能隐藏此代码
add_filter( 'wc_add_to_cart_message_html', '__return_false' );
你可以在这里找到更多信息hide added to your cart
【讨论】: