You are here

function commerce_vat_components in Commerce VAT 7

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

Parameters

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

Return value

An array of vat price component arrays.

File

./commerce_vat.module, line 671
Defines VAT rates and Rules integration for configuring vat rules for applicability and display.

Code

function commerce_vat_components($components) {
  $component_types = commerce_vat_commerce_price_component_type_info();
  $vat_components = array();

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

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

      // Add the component to the vat components array.
      $vat_components[] = $component;
    }
  }
  return $vat_components;
}