class TaxRateResolver in Commerce Core 8.2
Hierarchy
- class \Drupal\commerce_tax_test\Resolver\TaxRateResolver implements TaxRateResolverInterface, TaxTypeAwareInterface uses TaxTypeAwareTrait
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\ResolverView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TaxRateResolver:: |
public | function |
Resolves the tax rate for the given tax zone. Overrides TaxRateResolverInterface:: |
|
TaxRateResolverInterface:: |
constant | |||
TaxTypeAwareTrait:: |
protected | property | The tax type. | |
TaxTypeAwareTrait:: |
public | function |