Tagged: ismael
Hello!
is it possible to add a custom radiobox named “Geschlecht” before Vorname? You can either choose “männlich” or “weiblich”.
Link: http://www.ameisenhaufen.at/dev/uliss/kasse/
Thanks in advance.
Marc
Hey hostedbymarc,
Thank you for using Enfold.
I’m not sure if the radio button field is valid in the checkout but if you want to add the gender as a select element, please add this in the functions.php file.
function array_move($key, $new_index, $array)
{
if($new_index < 0) return;
if($new_index >= count($array)) return;
if(!array_key_exists($key, $array)) return;
$ret = array();
$ind = 0;
foreach($array as $k => $v)
{
if($new_index == $ind)
{
$ret[$key] = $array[$key];
$ind++;
}
if($k != $key)
{
$ret[$k] = $v;
$ind++;
}
}
// one last check for end indexes
if($new_index == $ind)
$ret[$key] = $array[$key];
return $ret;
}
add_filter('woocommerce_checkout_fields', 'woocommerce_checkout_fields_mod', 10, 1);
function woocommerce_checkout_fields_mod($fields) {
$fields['billing']['billing_gender'] = array(
'label' => 'Gender',
'placeholder' => 'Gender',
'type' => 'select',
'options', 'options' => array(
'male' => 'Male',
'female' => 'Female',
),
'required' => true,
'class' => array( 'form-row-wide', 'gender-field')
);
$fields['billing'] = array_move('billing_gender', 3, $fields['billing']);
return $fields;
}
Best regards,
Ismael