如何解决如何删除 WooCommerce 中的“运费更新”消息
我正在使用它来删除 Woocommerce 中的“购物车已更新”消息:
add_filter( 'woocommerce_add_message','__return_false');
解决方法
在shortcodes/class-wc-shortcode-cart.php我们找到
wc_add_notice( __( 'Shipping costs updated.','woocommerce' ),'notice' );
在includes/wc-notice-functions.php中我们发现,在wc_add_notice
函数中
// Backward compatibility.
if ( 'success' === $notice_type ) {
$message = apply_filters( 'woocommerce_add_message',$message );
}
$message = apply_filters( 'woocommerce_add_' . $notice_type,$message );
因此,您可以使用 woocommerce_add_message
过滤器钩子代替 woocommerce_add_"$notice_type"
过滤器钩子。然后您将比较通知消息,如果这足够了,我们将返回 false。
所以你得到:
function filter_woocommerce_add_notice ( $message ) {
// Equal to (Must be exactly the same).
// If the message is displayed in another language,adjust where necessary!
if ( $message == 'Shipping costs updated.' ) {
return false;
}
return $message;
}
add_filter( 'woocommerce_add_notice','filter_woocommerce_add_notice',10,1 );
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。