更改 WooCommerce 通知在店面主题中的位置
Change the position of of WooCommerce notices in storefront theme
我正在尝试更改 storefront_shop_messages 在我的店面 (WooCommerce) 子主题中的位置。所以我在我的活动主题的 functions.php 中添加了这段代码:
remove_action( 'storefront_content_top', 'storefront_shop_messages', 15 );
add_action('woocommerce_product_meta_end', 'storefront_shop_messages', 1 );
但是不行。
获得您在评论中所期望的内容的正确方法(意味着仅在产品单页上添加到购物车按钮后显示 WooCommerce 通知):
add_action( 'wp_head', 'customize_notices' );
function customize_notices(){
if( is_product() )
remove_action( 'storefront_content_top', 'storefront_shop_messages', 15 );
remove_action( 'woocommerce_before_single_product', 'wc_print_notices', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_before_main_content', 34 );
}
代码进入您的活动子主题(或主题)的 function.php 文件或任何插件文件。
已使用 WooCommerce 3.1+ 测试并处理店面主题
我正在尝试更改 storefront_shop_messages 在我的店面 (WooCommerce) 子主题中的位置。所以我在我的活动主题的 functions.php 中添加了这段代码:
remove_action( 'storefront_content_top', 'storefront_shop_messages', 15 );
add_action('woocommerce_product_meta_end', 'storefront_shop_messages', 1 );
但是不行。
获得您在评论中所期望的内容的正确方法(意味着仅在产品单页上添加到购物车按钮后显示 WooCommerce 通知):
add_action( 'wp_head', 'customize_notices' );
function customize_notices(){
if( is_product() )
remove_action( 'storefront_content_top', 'storefront_shop_messages', 15 );
remove_action( 'woocommerce_before_single_product', 'wc_print_notices', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_before_main_content', 34 );
}
代码进入您的活动子主题(或主题)的 function.php 文件或任何插件文件。
已使用 WooCommerce 3.1+ 测试并处理店面主题