I have a function that\'s working properly except for it displays the notice twice in the cart instead of once. The function applies a discount and also shows a notice. The
The multiple notices were caused when the customer updated the cart with the Update Cart button so a quick fix was simply clearing notices every time the customer clicked the Update Cart button.
It would be better to solve the problem at its source which would be finding a different way to display notices without duplication but until then this gets the desired effect.
//clear notices on cart update
function clear_notices_on_cart_update() {
wc_clear_notices();
};
// add the filter
add_filter( 'woocommerce_update_cart_action_cart_updated', 'clear_notices_on_cart_update', 10, 1 );