You are here

class TaxRateResolver in Commerce Core 8.2

Hierarchy

Expanded class hierarchy of TaxRateResolver

1 string reference to 'TaxRateResolver'
commerce_tax_test.services.yml in modules/tax/tests/modules/commerce_tax_test/commerce_tax_test.services.yml
modules/tax/tests/modules/commerce_tax_test/commerce_tax_test.services.yml
1 service uses TaxRateResolver
commerce_tax_test.tax_rate_resolver in modules/tax/tests/modules/commerce_tax_test/commerce_tax_test.services.yml
Drupal\commerce_tax_test\Resolver\TaxRateResolver

File

modules/tax/tests/modules/commerce_tax_test/src/Resolver/TaxRateResolver.php, line 14

Namespace

Drupal\commerce_tax_test\Resolver
View source
class TaxRateResolver implements TaxRateResolverInterface, TaxTypeAwareInterface {
  use TaxTypeAwareTrait;

  /**
   * {@inheritdoc}
   */
  public function resolve(TaxZone $zone, OrderItemInterface $order_item, ProfileInterface $customer_profile) {

    // Confirm that a tax type is always set.
    assert($this->taxType instanceof TaxTypeInterface);

    // Use the "reduced" rate for order items with a quantity larger than 20.
    if (Calculator::compare($order_item
      ->getQuantity(), '20') == 1) {
      return $zone
        ->getRate('reduced') ?: $zone
        ->getDefaultRate();
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TaxRateResolver::resolve public function Resolves the tax rate for the given tax zone. Overrides TaxRateResolverInterface::resolve
TaxRateResolverInterface::NO_APPLICABLE_TAX_RATE constant
TaxTypeAwareTrait::$taxType protected property The tax type.
TaxTypeAwareTrait::setTaxType public function