woocommercewoocommerce-checkout-fields

Woocommerce: hook to move the ‘field description’ below the ‘label’?


I need to create a hook to move the ‘field description’ below the ‘label’ instead of below the input field.

Take a look at this capture to see what I mean: https://monosnap.com/file/O0ZFx60KoxoQlC7ZmZbJR8eVPh7EbF

I read the documentation but, as far as I see there now way to do this: https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/

Can this be done?


Solution

  • The form fields in your checkout are being generated by the woocommerce_form_field() function. This has two filters that will let you either filter the fields by type: woocommerce_form_field_{type} Or the fields in general: woocommerce_form_field.

    Unfortunately there is no filter that will let you easily rearrange the HTML generated by the woocommerce_form_field() function, so you would have to use one of the above filters and basically rebuild the whole form field by copying the code from the woocommerce_form_field() function and rearrange the part where the $field_html is constructed.