Created
June 7, 2024 13:45
-
-
Save WpComet/ed78e38d4e21142d513887ad6e435c09 to your computer and use it in GitHub Desktop.
Making WooCommerce coupon codes work with accented - special - characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Tested with Turkish letters like İ or Ğ, should work with other languages as well like German Ç or Czech Č etc. etc. | |
| add_filter( 'woocommerce_coupon_code', 'make_coupons_case_insensitive' ); | |
| function make_coupons_case_insensitive( $coupon_code ) { | |
| // Convert special characters to ASCII | |
| $coupon_code = iconv('UTF-8', 'ASCII//TRANSLIT', $coupon_code); | |
| // Change all coupon codes to lowercase | |
| return strtolower( $coupon_code ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment