You are here

function commerce_tax_components in Commerce Core 7

Returns an array of tax components from a price components array.

Parameters

$components: A price's components array including potential tax components.

Return value

An array of tax price component arrays.

File

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

Code

function commerce_tax_components($components) {
  $component_types = commerce_tax_commerce_price_component_type_info();
  $tax_components = array();

  // Loop over each component passed in...
  foreach ($components as $component) {

    // Looking for components that match one of the defined tax price components.
    if (array_key_exists($component['name'], $component_types)) {

      // Add the component to the tax components array.
      $tax_components[] = $component;
    }
  }
  return $tax_components;
}