A
A
Andrey Dimakov2021-05-24 07:42:54
WordPress
Andrey Dimakov, 2021-05-24 07:42:54

Correct output of product delivery forms?

I have difficulties with the output of the delivery forms in the correct form, namely in the customization of forms, since there is no html code (at least I did not find it).
The code should be like this:

<div class="zagolovok">
  <p class="wrtadres">Введите адрес</p>
  <input class="wrtadres_form" type="text" name="adress" placeholder="ул. Lorem Ipsum">
</div>

and look like this: 60aa68cee2b84518585615.png
I managed to do it, but the problem is this: how to pick up all the WooCoomerce classes (I can get the id, fortunately), so that later everything will work and not have to dance with a tambourine?
WooCommerce code ( note the classes and values ​​in the tag ):
<p class="form-row form-row-first validate-required thwcfe-input-field-wrapper validate-required" id="billing_first_name_field" data-priority="30" data-rules="" data-rules-action="" data-validations="validate-required"><label for="billing_first_name" class="">Имя <abbr class="required" title="обязательно">*</abbr></label><span class="woocommerce-input-wrapper"><input type="text" class="input-text thwcfe-input-field" name="billing_first_name" id="billing_first_name" placeholder="" value="" autocomplete="given-name"  /></span></p>

The final piece of code from functions.php:
function change_woocommerce_field_markup($field, $key, $args, $value) {
    if( $key === 'billing_first_name') {
        $field = '<div class="zagalovok">
        <p class="wrtadres " id="'.esc_attr($key).'">Ваш адрес</p>
        <input class="wrtadres_form" type="text" name="adress">
        </div>';
    }
    return $field;
} 

add_filter("woocommerce_form_field","change_woocommerce_field_markup", 10, 4);

PS I need to receive classes and values ​​not only for this form.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question