I'm trying to add a note directly under the state field on the checkout form:
With something like this:
"If you need medication mailed outside of NC or SC, or you are not a client, please call".
I've tried various methods to accomplish this, but none seem to work. I've tried using CSS:
#billing_state:after {
content: "If you need medication mailed outside of NC or SC, or you are not a client, please call";
font-size: 14px;
color: red;
}
I've also tried adding this to the functions.php file:
add_filter('woocommerce_form_field_text', function ($field, $key, $args, $value) {
if ($key === 'billing_state') {
$field .= 'If you need medication mailed outside of NC or SC, or you are not a client, please
call';
}
return $field;
}, 10, 4);
But neither of these methods are working. This is the code for the state field I'm trying to target:
Your css rules didn't work because it's a
select
tag and you can't use csspseudo elements
onselect
tags!!! If you want more info on this topic, you could read about it on the following pages:and
Now in order to get css rules to work the way you want it, you need to target a different html element with your css!
This should work but if it didn't, then I would use the following method as an
alternative way
:The snippet above, will generate a new text field. A way to make it work the way you want, you could do the following instead:
and then add this to your style sheet of your active theme or active child theme!