php - 从帐户内容中删除 WooCommerce 消息
问题描述
我目前正在尝试使用以下代码行从 WooCommerce 帐户中删除所有消息:
remove_action( 'woocommerce_account_content', 'woocommerce_output_all_notices', 10 );
可悲的是,消息的包装器仍然存在:
<div class="woocommerce-notices-wrapper">lol</div>
我在lol
显示包装器的函数中添加了一个,这是我要删除的正确函数。不知道为什么它不起作用...
解决方案
如果您的活动主题使用默认的 woocommerce 模板和 myaccount 页面的挂钩,则添加以下代码片段以实现上述目的 -
function modify_wc_hooks() {
// remove all wc my account's notices wrapper
remove_action( 'woocommerce_account_content', 'woocommerce_output_all_notices', 5 );
remove_action( 'woocommerce_before_customer_login_form', 'woocommerce_output_all_notices', 10 );
remove_action( 'woocommerce_before_lost_password_form', 'woocommerce_output_all_notices', 10 );
remove_action( 'before_woocommerce_pay', 'woocommerce_output_all_notices', 10 );
remove_action( 'woocommerce_before_reset_password_form', 'woocommerce_output_all_notices', 10 );
}
add_action( 'init', 'modify_wc_hooks', 99 );
代码转到您的活动主题的functions.php
推荐阅读
- python - Python 3 问题
- neo4j - 无法从以下位置构造日期时间:NO_VALUE(处理文件时失败
- blazor - 如何从 Blazor 组件 (.razor) 导航到 .cshtml 页面?
- javascript - RegExp - 如何检查字符串是否在特定位置包含子字符串?
- vue.js - 如何使用 vuetify 禁用 nuxt js 中的波纹?
- html - 没有换行的多个文本标签
- python-3.x - 深度 Q 学习在算法交易中表现不佳
- ubuntu - 火狐坚持显示服务器IP而不是域名
- swift - Sync 不同步并且无法将数组填充到 DispatchQueue
- html - 如果我使用填充可用,则无法使用百分比高度