I’m adding some custom fields to my checkout page, with following code:
add_action( 'woocommerce_before_order_notes', 'bs_custom_checkout_fields' );
function bs_custom_checkout_fields( $checkout ) {
woocommerce_form_field( 'order_domain_name', array(
'type' => 'text',
'class' => array('my-field-class form-row-wide'),
'label' => __('Name','bs'),
'placeholder' => __('Enter the name','bs'),
'required' => true,
), $checkout->get_value( 'order_domain_name' ));
}
I would need to add some additional description before this field, to explain the user what this field means. Is there way to do that?
Thanks
Use the
description
parameter:}
I found two options to fix this in a way that will be safe with WooCommerce updates.
One way is to use the filter ‘woocommerce_form_field’. This passes the $
field
variable as well as$key
,$args
,$value
for the field. You can edit the output, but this is a bit tedious and may need updating in the future.A much more simple option is to change it through CSS by utilizing flexbox. I added the following CSS code to move the description above the form fields:
This is in answer to putting the description underneath the label.
You need to hack
/plugins/woocommerce/includes/wc-template-functions.php
Move the Line 2103 –
$field_html .= $field;
to Line 2108.
That’s all you can do, not WooCommerce update proof unfortunately.