• Resolved Kristad

    (@kristad)


    Hi
    How can I add a link to the label ? Like I have read terms and conditions – but want a link to the terms and conditions page. I added to label but it comes out showing the html when not checked off…

    Thanks.

    The page I need help with: [log in to see the link]

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

    (@themehigh)

    We believe that you are using the premium version fo our plugin.

    As per the WordPress forum policy, we can’t answer premium related questions on this forum. Could you please raise a ticket through our website? We hope our technical team will be able to help you.

    Thank you!

    Thread Starter Kristad

    (@kristad)

    No I do not believe I am using premium plugin. Can you confirm that? Thanks.

    Plugin Author ThemeHigh

    (@themehigh)

    You can follow the sample format given below while inserting the link as Label of the field.

    Text before the link <a href="URL that you want to link to" target="_blank"> Text to be displayed as Link</a>

    We hope this will help.

    Thank you!

    Thread Starter Kristad

    (@kristad)

    I did place the link that way and if I don’t fill out check out form correctly, I get the following message which shows the html:

    I have read the Terms & Conditions is a required field.
    I have read the Return Policy is a required field.
    For California Residents – I have read and understood the Prop 65 is a required field.

    I don’t want the html to show in the error message. What can I do?
    Thanks.

    Plugin Author ThemeHigh

    (@themehigh)

    Unfortunately, there is no option available in our plugin. However, by default WooCommerce provides a filter “woocommerce_checkout_required_field_notice” using which we can alter the error message.

    A sample code is given below:

    add_filter('woocommerce_checkout_required_field_notice', 'thwcfd_change_error_message', 10, 2);
    function thwcfd_change_error_message($error, $field_label){
     if($field_label == 'Billing Text before the link <a href="URL that you want to link to" target="_blank"> Text to be displayed as Link</a>'){
       return '<strong>' . ( $field_label ) . '</strong> is a required field';
     }
     return $error;
    }

    In the above code the label provided for the field is given below:

    Text before the link <a href="URL that you want to link to" target="_blank"> Text to be displayed as Link</a>

    We hope this will help.

    Thank you!

    Thread Starter Kristad

    (@kristad)

    Hi
    Thank you for that info. Where would I put this code? What file?

    Plugin Author ThemeHigh

    (@themehigh)

    You need to add the above code in your child theme’s functions.php.

    Thank you!

    Thread Starter Kristad

    (@kristad)

    Hi
    Thank you for getting back to me…
    I tried this but does not seem to work… The html link code still shows…

    So I put the first part in the child theme function.php
    and the second part is the label?
    Just want to confirm. Is this correct?

    Plugin Author ThemeHigh

    (@themehigh)

    If you would like to change the error message then you can change the below text in the above code with the error message that you would like to provide.

    '<strong>' . ( $field_label ) . '</strong> is a required field';

    For example,

    add_filter('woocommerce_checkout_required_field_notice', 'thwcfd_change_error_message', 10, 2);
    function thwcfd_change_error_message($error, $field_label){
     if($field_label == 'Billing Text before the link <a href="URL that you want to link to" target="_blank"> Text to be displayed as Link</a>'){
       return 'Terms and condition is a required field';
     }
     return $error;
    }

    We hope this will help.

    Thank you!

    Thread Starter Kristad

    (@kristad)

    Thank you for that. It worked for changing the error message for one checkbox.

    The code provided allowed me to make changes for text output of Return Policy but we cannot for change for Terms and Conditions.
    Problem is the function used can only be used once.

    Is there a way to change the error message for the second checkbox link?

    Thank you.

    Thread Starter Kristad

    (@kristad)

    Hi
    Does anyone know a way to change the second error message for the second checkbox? ThemeHigh – Is there a way?
    Thank you.

    Plugin Author ThemeHigh

    (@themehigh)

    You can modify the code as given below:

    add_filter('woocommerce_checkout_required_field_notice', 'thwcfd_change_error_message', 10, 2);
    function thwcfd_change_error_message($error, $field_label){
     if($field_label == 'Billing Text before the link <a href="URL that you want to link to" target="_blank"> Text to be displayed as Link</a>'){
       return 'Terms and condition is a required field';
     }else if($field_label == 'Second label'){
       return 'Second label error';
     }else if($field_label == 'Third label'){
       return 'Third label error';
     }
    
     return $error;
    }

    We hope this will help.

    Thank you!

    As I was the one working with the OP on this I wanted to update and add that the code above worked as desired. The one difference I made is to use ‘elseif’ as one word instead of two as the one word syntax works in cases where two words would not and is easier to remember. ??

    Thanks for the help.

    Plugin Author ThemeHigh

    (@themehigh)

    Great!

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Add html link in label’ is closed to new replies.