• Resolved lenamtl

    (@lenamtl)


    Hi,

    I’m trying to hide all coupon notification based on coupon code.

    Some coupon are nodiscount item so it does not make sense to display notifications for it.

    case: user add Product A, Product B at regular price(nodiscount) is automatically added to the cart. (message added…. is hidden with the code below)

    If product A is removed from the cart, product B stay in the cart as (nodiscount item) but a promo notification is display saying that is not vaid anymore = I’m looking for a way to hide it.

    This code work fine to hide the promo add to cart notification

    add_filter('woocommerce_coupon_message', function($msg, $msg_code, $coupon) {    
     if ('COUPON_CODE' === $coupon->get_code() && 200 === $msg_code) {        
         $msg = '';    
     }     return $msg;  }, 20, 3);

    This code is not working when removing product A from the cart (promo is no longuer valid) notification is displayed and I want to hide it.

    I have tried notification code 101,100,110 or 201…
    And I have also tried the entire code list…

    add_filter('woocommerce_coupon_message', function($msg, $msg_code, $coupon) {    
     if ('COUPON_CODE' === $coupon->get_code() && 101 === $msg_code) {        
         $msg = '';    
     }     return $msg;  }, 20, 3);

    I don’t know if this is a bug or maybe I’m not using the correct method.

    Also I’m wondering what would be the code all coupon notification for a temporary solution.

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support con

    (@conschneider)

    Engineer

    Hi there,

    I have tried notification code 101,100,110 or 201…
    And I have also tried the entire code list…

    Maybe adding Javascript to the mix with PHP control statements could do the trick.

    Also I’m wondering what would be the code all coupon notification for a temporary solution.

    As in hide all coupon message for all coupons and message types? I would probably use CSS for this.

    Kind regards,

    Thread Starter lenamtl

    (@lenamtl)

    CSS and JS cannot be use for this case, PHP is the only solution.
    I have opened a ticket because this seems to be a bug.
    I have found a work around, I will test it first and I will provide solution soon.

    Mirko P.

    (@rainfallnixfig)

    Hi @lenamtl,

    I’m going to leave this thread open for a bit to see if anyone is able to chime in to help out.

    Please let us know how testing goes, and feel free to reply on this thread with your findings.

    Thanks.

    Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    We’ve not seen any activity on this thread for a while, so I’m marking this thread as resolved.

    Hopefully, you were able to find a solution to your problem! If you have further questions, please feel free to open a new topic.

    Cheers!

    Thread Starter lenamtl

    (@lenamtl)

    Hi,

    here is the related ticket
    https://github.com/woocommerce/woocommerce/issues/30098

    • This reply was modified 3 years, 9 months ago by lenamtl.
    • This reply was modified 3 years, 9 months ago by lenamtl.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Hide coupon notification’ is closed to new replies.