You are here

function commerce_tax_rates in Commerce Core 7

Returns an array of tax rate objects keyed by name.

9 calls to commerce_tax_rates()
commerce_tax_commerce_price_component_type_info in modules/tax/commerce_tax.module
Implements hook_commerce_price_component_type_info().
commerce_tax_default_rules_configuration in modules/tax/commerce_tax.rules_defaults.inc
Implements hook_default_rules_configuration().
commerce_tax_field_widget_form_alter in modules/tax/commerce_tax.module
Implements hook_field_widget_form_alter().
commerce_tax_rate_load in modules/tax/commerce_tax.module
Returns a single tax rate object.
commerce_tax_rate_titles in modules/tax/commerce_tax.module
Returns the titles of every tax rate keyed by name.

... See full list

1 string reference to 'commerce_tax_rates'
commerce_tax_rates_reset in modules/tax/commerce_tax.module
Resets the cached list of tax rates.

File

modules/tax/commerce_tax.module, line 147
Defines tax rates and Rules integration for configuring tax rules for applicability and display.

Code

function commerce_tax_rates() {

  // First check the static cache for a tax rates array.
  $tax_rates =& drupal_static(__FUNCTION__);

  // If it did not exist, fetch the types now.
  if (!isset($tax_rates)) {
    $tax_rates = array();

    // Find tax rates defined by hook_commerce_tax_rate_info().
    foreach (module_implements('commerce_tax_rate_info') as $module) {
      foreach (module_invoke($module, 'commerce_tax_rate_info') as $name => $tax_rate) {

        // Initialize tax rate properties if necessary.
        $defaults = array(
          'name' => $name,
          'display_title' => $tax_rate['title'],
          'description' => '',
          'rate' => 0,
          'type' => '',
          'rules_component' => 'commerce_tax_rate_' . $name,
          'default_rules_component' => TRUE,
          'price_component' => 'tax|' . $name,
          'calculation_callback' => 'commerce_tax_rate_calculate',
          'module' => $module,
        );
        $tax_rates[$name] = array_merge($defaults, $tax_rate);
      }
    }

    // Last allow the info to be altered by other modules.
    drupal_alter('commerce_tax_rate_info', $tax_rates);
  }
  return $tax_rates;
}