Reputation:
I am using Woocommerce and I need to move the Woocommerce messages (most importantly ALL messages that are displayed on the single product page) to ABOVE the page title (my theme is using the product title as the page title). I know I can remove one message by using
add_filter( 'wc_add_to_cart_message', 'remove_add_to_cart_message' );
function remove_add_to_cart_message() {
return;
}
but I need it for all single-product-page messages, and I need them to be readded again above the page title.
Upvotes: 0
Views: 1570
Reputation: 415
The best way to do that is to remove it first and then hook where you want
Use this code in functions.php
add_action( 'wp_head', 'customize_notices' );
function customize_notices(){
if( is_product() )
remove_action( 'woocommerce_before_single_product', 'woocommerce_output_all_notices', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_output_all_notices', 99 );
}
Upvotes: 0
Reputation: 731
I'm not sure what version it changed in, but the action has changed to woocommerce_output_all_notices
so it should be...
remove_action( 'woocommerce_before_single_product', 'woocommerce_output_all_notices', 10 );
Tested on 3.7.0
Upvotes: 0