How To add custom radio boxes to WooCommerce Billing page and change total price by this field?

Lets say i need to add custom radio fields ( company or person ) at the top of the form to the billing for. And if the visitor checks person they should pay 21% Tax and they select company that is localated in NL they also should pay 21% tax. Any other case they should be free of tax? Any ideas ?

This is what i’ve tried :

add_filter('woocommerce_billing_fields', 'custom_woocommerce_billing_fields');

function custom_woocommerce_billing_fields($fields){

$fields['customer_type'] = array(
    'label' => __('Bedrijf', 'woocommerce'),
    'placeholder' => _x('Bedrijf', 'placeholder', 'woocommerce'),
    'required' => false,
    'clear' => false,
    'type' => 'checkbox',
    'class' => array('my-css'),
);

$fields['customer_type_personal'] = array(
    'label' => __('Persoonlijke', 'woocommerce'),
    'placeholder' => _x('Persoonlijke', 'placeholder', 'woocommerce'),
    'required' => false,
    'clear' => false,
    'type' => 'checkbox',
    'class' => array('my-css-2'),
);

return $fields;

}

1 Answer
1

Try it

add_filter('woocommerce_billing_fields', 'custom_woocommerce_billing_fields');

function custom_woocommerce_billing_fields($fields)
{

    $fields['billing_options'] = array(
        'label' => __('Ordering Method', 'woocommerce'), // Add custom field label
        'placeholder' => _x('Your NIF here....', 'placeholder', 'woocommerce'), // Add custom field placeholder
        'required' => true, // if field is required or not
        'clear' => false, // add clear or not
        'type' => 'radio', // add field type
        'class' => array('form-group'),    // add class name
        'options'         => array(
        'privato_cittadino'         => 'Privato cittadino',
        'azienda_professionista'    => 'Azienda o libero professionista',
      ),

    );

Leave a Comment