You are here

function commerce_tax_ui_tax_rate_delete in Commerce Core 7

Deletes a tax rate.

Parameters

$name: The machine-name of the tax rate.

$skip_reset: Boolean indicating whether or not this delete should result in entities being reset and the menu being rebuilt; defaults to FALSE. This is useful when you intend to perform many deletions at once, as menu rebuilding is very costly in terms of performance.

1 call to commerce_tax_ui_tax_rate_delete()
commerce_tax_ui_tax_rate_delete_form_submit in modules/tax/includes/commerce_tax_ui.admin.inc
Submit callback for commerce_tax_ui_tax_rate_delete_form().

File

modules/tax/commerce_tax_ui.module, line 440
Provides a UI for creating simple tax types and rates.

Code

function commerce_tax_ui_tax_rate_delete($name, $skip_reset = FALSE) {
  $tax_rate = commerce_tax_rate_load($name);
  db_delete('commerce_tax_rate')
    ->condition('name', $name)
    ->execute();
  commerce_tax_rates_reset();
  rules_config_delete(array(
    rules_config_load($tax_rate['rules_component'])->id,
  ));

  // Clear the necessary caches and rebuild the menu items.
  if (!$skip_reset) {
    entity_defaults_rebuild();
    rules_clear_cache(TRUE);
    variable_set('menu_rebuild_needed', TRUE);
  }

  // Notify other modules that this tax rate has been deleted.
  module_invoke_all('commerce_tax_rate_delete', $tax_rate, $skip_reset);
}