## relocate woocommerce notices/messages on Cart page

Question

EDIT: see solution below from @motivast. With his basic setup you can then make whatever changes you’d like to specific auto-scroll actions and relocate whichever specific notices you want. My final solution also includes hooking a blank div within the coupon form and then targeting the coupon notices there, like this:

/* Add div to hook coupon notices to */
add_action ('woocommerce_cart_coupon' , 'coupon_notices_div' , 1 );
function coupon_notices_div() {
echo "";
?>
<div class="cart-coupon-notices"></div>
<?php
}


With that in your custom plugin php file, you can then use .cart-coupon-notices instead of .cart-collaterals in @motivast’s solution. This places the coupon notices immediately below the “apply coupon” button.

Original question:

I’ve found many examples of how to do this for the “added to cart” notice on products/shop pages, but the cart page seems to be altogether different. The notices I want to move more than any others are the coupon notices (i.e. “coupon applied successfully” etc.). Auto-scrolling the customers to the top of the page when they add a coupon is quite annoying for them.

The solution everyone talks about is that you need to just relocate wc_print_notices from the top of the cart page to somewhere else (I want it hooked to woocommerce_before_cart_totals), but no matter what I do the notices are still at the top of the page.

There are several variations of this question on stackexchange, none with any answers that work.

I’ve tried all the options listed here, but no luck.

I’ve tried playing with variations from here, also no luck.

I’ve tried the options from here, and… no luck.

Other variations of the same problem: here, here, a possible solution that works only with the storefront theme here.

Any help would be hugely appreciated!

EDIT: Two threads from elsewhere helping to solve this issue:

https://wordpress.org/support/topic/relocate-coupon-notices-on-cart-page/

0
2 years 2020-12-16T19:10:20-05:00 0 Answers 6 views 0