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.
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.
WooCommerce renders messages by using
woocommerce_show_messages()
function. This function is hooked towoocommerce_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.If you want to render messages in another place, then just call
woocommerce_show_messages()
function in desired place.You can also add a 3rd parameter for positioning priority if needed.
Source Woo Hooks
Since 2.1.0 woocommerce_show_messages is a deprecated function. You should use wc_print_notices instead: