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

Question

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;

}

0
WPTricks 2 months 0 Answers 8 views 0

Leave an answer