You are here

function uc_tax_get_included_tax in Ubercart 8.4

Calculates the taxes that should be included in a product's display price.

Parameters

$product: The product whose included taxes are to be calculated.

\Drupal\uc_order\OrderInterface $order: The order object being considered.

Return value

array An array with two items: the taxed amount and any suffixes that should be printed after the product price.

2 calls to uc_tax_get_included_tax()
uc_tax_entity_view_alter in uc_tax/uc_tax.module
Implements hook_entity_view_alter().
uc_tax_uc_product_alter in uc_tax/uc_tax.module
Implements hook_uc_product_alter().

File

uc_tax/uc_tax.module, line 552
Ubercart Tax module.

Code

function uc_tax_get_included_tax($product, OrderInterface $order = NULL) {
  $amount = 0;
  $suffixes = [];
  foreach (uc_tax_filter_rates($order) as $tax) {
    if ($tax->display_include) {
      $taxable = uc_tax_apply_item_tax($product, $tax);
      if (!empty($taxable)) {
        $amount += $taxable * $tax->rate;
        $suffixes[$tax->inclusion_text] = $tax->inclusion_text;
      }
    }
  }
  return [
    $amount,
    $suffixes,
  ];
}