Reposition Woocommerce Message

I’m trying to reposition the messages in my Woocommerce theme. For example the successfully added to cart message. They appear to automatically be placed at the very top of where the woocommerce wrapper start begins.

I’ve already found this link which allows me to change the wording of the message but what I need is to remove the message from where it is and reposition it elsewhere.

Read More

I’ve scoured the woocommerce forum, this forum and the woocommerce template files. There is a messages.php but that only appears to contain the markup for the messages. I cannot figure out how to change where the messages appear. Any help on this would be greatly appreciated.

Related posts

3 comments

  1. WooCommerce renders messages by using woocommerce_show_messages() function. This function is hooked to woocommerce_before_single_product action. So if you don’t want to render messages before single product, you need to remove that hook for the action.

    remove_action( 'woocommerce_before_single_product', 'woocommerce_show_messages' );
    

    If you want to render messages in another place, then just call woocommerce_show_messages() function in desired place.

  2. remove_action( 'woocommerce_before_single_product', 'woocommerce_show_messages' );
    add_action( 'woocommerce_after_single_product', 'woocommerce_show_messages', 15 );
    

    You can also add a 3rd parameter for positioning priority if needed.

    Source Woo Hooks

  3. Since 2.1.0 woocommerce_show_messages is a deprecated function. You should use wc_print_notices instead:

    remove_action( 'woocommerce_before_single_product', 'wc_print_notices' );
    

Comments are closed.