• Resolved odamli

    (@odamli)


    Hi

    I wanted to customize validation in Billing section , so I use this code and it did work.
    if ( ! function_exists( ‘wmsc_validate_fname_lname’ ) ) {
    function wmsc_validate_fname_lname( $errors, $fields ) {
    if ( preg_match( ‘/\\d/’, $fields[ ‘billing_first_name’] ) ) {
    $errors[ ‘billing_first_name’ ] = __( ‘<b>Billing First name</b> field does not allow numbers.’ );
    }
    if ( preg_match( ‘/\\d/’, $fields[ ‘billing_last_name’] ) ) {
    $errors[ ‘billing_last_name’ ] = __( ‘<b>Billing Last name</b> field does not allow numbers.’ );
    }
    return $errors;
    }
    }
    add_action( ‘wmsc_custom_validation’, ‘wmsc_validate_fname_lname’, 10, 2 );

    But the problem is I can’t translate “Billing Last name field does not allow numbers.” into Chinese in this way.
    Is there a way to adjust it into text so that I could translate it into Chinese?

    Regards

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author SilkyPress

    (@diana_burduja)

    Why can’t you translate it into Chinese? Simply writing the Chinese translation instead of the string doesn’t work?

    Thread Starter odamli

    (@odamli)

    no it shows “syntax error, unexpected ‘ ‘ (T_STRING)” after I translate it into Chinese in functions.php

    Plugin Author SilkyPress

    (@diana_burduja)

    I just tried some chinese characters for the string in the code you’ve pasted. Here is a screenshot. But I don’t manage to replicate the syntax error you’re receiving.

    Here is a screenshot of the validation messages on my checkout page. As you can see, the validation function recognized that there are numbers in the first and the last name and the validation messages were output correctly.

    Could you give me the exact code, including the translated strings, that you are trying out and gives the syntax error?

    Also, a screenshot of the code will be useful, as this forum modifies the quotes in the code.

    • This reply was modified 5 years, 8 months ago by SilkyPress.
    Thread Starter odamli

    (@odamli)

    Hi

    You tried to copy and paste and it worded so I tried to type them in somewhere else and then copy and paste them and suddenly it all worded out.
    It might be some string errors when directly typing in function.php cuz even when I typed in numbers and letters it shows errors. Copy and paste can avoid that error.

    Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Numbers are not allowed in Name fields’ is closed to new replies.