On my magento 2.4 I have a few coupon codes that should only be available to the admins via backend, which means that the customers on the frontend should not be able to use them. I was able to achieve this for the coupon block on the cart page by creating a Plugin on the MagentoCheckoutControllerCartCouponPost::execute()
method. This method, however, doesnt work for the coupon block on the checkout page.
What I do on the cart page is:
- check the coupon code entered by the user
- if the coupon code is one of the restricted coupon codes
- then removes the coupon from the cart and shows an “invalid code” error message to the user
How can I do the same on the checkout page? So when the user inserts the restricted coupon and clicks apply, I need to be able to not apply that coupon and send an error message instead