Home>

In the checkout form, users should be prevented from writing their first and last name in English.

I used this code to implement this, but it does not work correctly -an error occurs:

  • Artem NO LATIN= ALLOW ONLY CYRILLIC LETTERS and hyphen add_action('woocommerce_checkout_process', 'Speedplus_com_ua_latin_checkout_fields'); function Speedplus_com_ua_latin_checkout_fields() { $billing_first_name= filter_input(INPUT_POST, 'billing_first_name');

    $billing_last_name= filter_input(INPUT_POST, 'billing_last_name'); if (strlen(trim(preg_replace('/^[A-Yaa-iYe-]+$/', '', $billing_first_name))) > 0) { wc_add_notice(__('Be kind, write YOUR INITIALSUkrainian or Russian'), 'error'); }

if (strlen(trim(preg_replace('/^[A-Yaa-iYe-]+$/', '', $billing_last_name))) > 0) { wc_add_notice(__('Be kind, write YOUR INITIALSUkrainian or Russian'), 'error'); } }

Possible duplicate of question: How to prevent checkout in english, woocommerce?

SeVlad2022-01-18 19:15:15

The code must be formatted in the question as code, not as text. Use three backquote characters ` on an empty line at the beginning and end of a piece of code.

KAGG Design2022-01-18 19:15:15