• Resolved Simo2606

    (@simo2606)


    Hello,

    I have a added to checkout a checkbox field, that is necessary to check in order to proceed. If the user doesn’t check the field, it appears an error message that contains the label of the field with html included, like “Dichiaro di aver letto l'<a href=”https://…/privacy-policy/&#8221; style=”color: #000000″>Informativa sulla Privacy</a>. di fatturazione è un campo obbligatorio.”

    How can I hide the html part of the label or customize this error message?

    Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author ThemeHigh

    (@themehigh)

    Unfortunately, there is no direct option available in the lite version of our plugin to achieve your requirement.

    However, as a workaround, you can use the below code by adding it in your child theme’s functions.php file. Which will help you to completely modify the error message.

    add_filter('woocommerce_checkout_required_field_notice', 'thwcfd_change_field_label_error', 10, 2);
    function thwcfd_change_field_label_error($error_msg, $label){
    if($label === 'label of the field'){
    $error_msg = 'Required error msg';
    }
    return $error_msg;
    }

    In the above code, please replace label of the field with your corresponding field label and the Required error msg with your corresponding error message.
     
    Please note that this code will not work for default email, postcode, state fields.

    Thank you.

    Thread Starter Simo2606

    (@simo2606)

    Hello,

    thank you for your kind reply. I tried with the following code:

    add_filter('woocommerce_checkout_required_field_notice', 'thwcfd_change_field_label_error', 10, 2);
    function thwcfd_change_field_label_error($error_msg, $label){
    if($label === 'Dichiaro di aver letto l\'<a href="https://cantinamingazzini.it/privacy-policy/" style="color: #000000">Informativa sulla Privacy</a>.'){
    $error_msg = 'Leggi e accetta l\'informativa sulla privacy per procedere con l'ordine.';
    }
    return $error_msg;
    }

    but didn’t work… am I missing something?

    Thank you

    • This reply was modified 3 years, 2 months ago by Simo2606.
    Plugin Author ThemeHigh

    (@themehigh)

    Your issue needs a detailed check. Can you please raise a ticket through our website? We hope our technical team will be able to help you.

    Thank you!

    Thread Starter Simo2606

    (@simo2606)

    Your support team solved the problem! Thank you!

    Plugin Author ThemeHigh

    (@themehigh)

    Great!

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

The topic ‘Woocommerce error message with html included’ is closed to new replies.