Woocommerce cart notice showing multiple times

前端 未结 1 1196
误落风尘
误落风尘 2021-01-15 18:28

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

相关标签:
1条回答
  • 2021-01-15 18:53

    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 ); 
    
    0 讨论(0)
提交回复
热议问题