You are here

public function ChainTaxRateResolver::resolve in Commerce Core 8.2

Resolves the tax rate for the given tax zone.

Parameters

\Drupal\commerce_tax\TaxZone $zone: The tax zone.

\Drupal\commerce_order\Entity\OrderItemInterface $order_item: The order item.

\Drupal\profile\Entity\ProfileInterface $customer_profile: The customer profile. Contains the address and tax number.

Return value

\Drupal\commerce_tax\TaxRate|string|null The tax rate, NO_APPLICABLE_TAX_RATE, or NULL.

Overrides TaxRateResolverInterface::resolve

File

modules/tax/src/Resolver/ChainTaxRateResolver.php, line 47

Class

ChainTaxRateResolver

Namespace

Drupal\commerce_tax\Resolver

Code

public function resolve(TaxZone $zone, OrderItemInterface $order_item, ProfileInterface $customer_profile) {
  $result = NULL;
  foreach ($this->resolvers as $resolver) {
    if ($resolver instanceof TaxTypeAwareInterface) {
      $resolver
        ->setTaxType($this->taxType);
    }
    $result = $resolver
      ->resolve($zone, $order_item, $customer_profile);
    if ($result) {
      break;
    }
  }
  return $result;
}