Skip to content

Enforce case-sensitivity for coupon code in cart/checkout

What is the best way to enforce case-sensitivity for coupon-code entries in the checkout and shopping cart? Meaning, if a coupon code is configured as “TEST” in the admin backend, then “test” should not work in the storefront.

I see the controller for the coupon code submission is located in vendor/magento/module-checkout/Controller/Cart/CouponPost.php. There is a line which loads the coupon code: $coupon->load($couponCode, ‘code’);

What is the best way to do this (i.e plugin class, etc..)? Thanks