Reputation: 259
I'd like to add an anchor link below the Country Dropdown in Woocommerce checkout fields.
I use the code below, but unfortunately without the desired result
add_action( 'woocommerce_form_field_text','additional_paragraph_after_billing_country', 10, 4 );
function additional_paragraph_after_billing_country( $field, $key, $args, $value ){
if ( is_checkout() && $key == 'billing_country' ) {
$field .= '<p class="form-row sf_add hide-on-desktop hide-on-tablet"><a href="#SF">extra paragraph here</a></p>';
}
return $field;
}
Image for illustration:
Any advice would be appreciated
Upvotes: 1
Views: 169
Reputation: 29614
If you want to add additional paragraph under a country field, you should use the woocommerce_form_field_country
hook
opposite woocommerce_form_field_text
More explanation can be found in: How should I change the woocommerce_form_field HTML Structure?
So you get:
function filter_woocommerce_form_field_country( $field, $key, $args, $value ) {
// Compare
if ( is_checkout() && $key === 'billing_country' ) {
$field .= '<p class="form-row sf_add hide-on-desktop hide-on-tablet"><a href="#SF">extra paragraph here</a></p>';
}
return $field;
}
add_filter( 'woocommerce_form_field_country', 'filter_woocommerce_form_field_country', 10, 4 );
Upvotes: 2