You are here

function _commerce_reports_tax_get_tax_rates in Commerce Reporting 7.4

Helper function for getting applied tax rate from line item wrapper.

Parameters

EntityDrupalWrapper $line_item_wrapper: The wrapped line item entity.

Return value

array An array set of tax rates from given line item.

1 call to _commerce_reports_tax_get_tax_rates()
commerce_reports_tax_order_save in modules/tax/commerce_reports_tax.module
Stores the tax information of an order.

File

modules/tax/commerce_reports_tax.module, line 339
Module file for Commerce Reports Tax.

Code

function _commerce_reports_tax_get_tax_rates(EntityDrupalWrapper $line_item_wrapper) {
  $commerce_total_data = $line_item_wrapper->commerce_total->data
    ->value();
  $tax_rates = array();
  foreach ($commerce_total_data['components'] as $component) {
    if (!empty($component['price']['data']['tax_rate']['name'])) {
      $tax_rates[$component['price']['data']['tax_rate']['name']] = commerce_tax_rate_load($component['price']['data']['tax_rate']['name']);
    }
  }
  return $tax_rates;
}