Vote up!
Vote down!

When I setup a VAT tax, how do I make it default to my new tax rate on the product add form?

We are using the inclusive VAT tax rate for all of the items in this shop.

On the Add Product form, I have to select the tax rate for every single item, even though there is only one tax rate available. I would like to be able to set this tax rate by default so my client doesn't have to understand.

Whats the best way to do that?


Asked by: dbazuin
on June 1, 2012


I was searching for a clear answer about this because I'm not a developer and sometimes it's difficult for me to find the proper solution if I don't have help from a caritative developer soul help or a workaround guide.

After much search I found this https://www.drupal.org/node/1199800#comment-6661812 in Drupal.org that is the solution for your/my question. I also post the code directly for all of those that wanted a solution to this

 * Implements hook_field_widget_form_alter().
 * Alter price widgets on the product form to have tax inclusive price by default
function my_module_field_widget_form_alter(&$element, &$form_state, $context) {
// Act on widgets for fields of type commerce_price on commerce_products.
if ($context['field']['type'] == 'commerce_price' && $context['instance']['entity_type'] == 'commerce_product') {
        if (isset(
$element['include_tax'])) {
$element['include_tax']['#default_value'] = 'tva';
//if(-----) : define your condition here if you do not want the input to appear for certain users.
            //  $element['include_tax']['#access'] = FALSE;

Hope this helps somebody

- pslcbs on January 15, 2015

1 Answer