Woocommerce modifying the html on the checkout page?
I'm trying to wrap 'some' of the fields of the checkout page in a div and inject some buttons because I am implementing some address validation.
Basically to start with I need a wrapper around company, address line 1, address line 2, town and postcode so I can show/hide them but I can't seem to get anything to work. Here's what I've tried -
In my filters file:
function change_woocommerce_field_markup($field, $key, $args, $value){
if($key === 'billing_company') {
$field = 'div class="address-wrapper"'.$field;
}
else if ($key === 'billing_postcode') {
$field = $field.'/div';
}
else {
$field = $field;
}
return $field;
}
add_filter('woocommerce_form_field', '\App\change_woocommerce_field_markup', 10, 4);
So I'm prepending and appending the relevant fields with the html that opens and closes the wrapper. However the resultant HTML looks like this:
div class="address-wrapper"/div
p class="form-row form-row-first validate-required" id="billing_first_name_field"....
p class="form-row form-row-last validate-required" id="billing_last_name_field"....
So it's putting the wrapper at the top of the container! I don't get it, what's going on with this?
Thanks Kevin
Topic woocommerce-offtopic Wordpress
Category Web