Skip to content

Instantly share code, notes, and snippets.

@WpComet
Created June 7, 2024 13:45
Show Gist options
  • Select an option

  • Save WpComet/ed78e38d4e21142d513887ad6e435c09 to your computer and use it in GitHub Desktop.

Select an option

Save WpComet/ed78e38d4e21142d513887ad6e435c09 to your computer and use it in GitHub Desktop.
Making WooCommerce coupon codes work with accented - special - 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