You are here

class ProductVariationTaxCodeResolver in Drupal Commerce Connector for AvaTax 8

Resolves tax code based on product variation value.

Hierarchy

Expanded class hierarchy of ProductVariationTaxCodeResolver

1 string reference to 'ProductVariationTaxCodeResolver'
commerce_avatax.services.yml in ./commerce_avatax.services.yml
commerce_avatax.services.yml
1 service uses ProductVariationTaxCodeResolver
commerce_avatax.product_variation_tax_code_resolver in ./commerce_avatax.services.yml
Drupal\commerce_avatax\Resolver\ProductVariationTaxCodeResolver

File

src/Resolver/ProductVariationTaxCodeResolver.php, line 11

Namespace

Drupal\commerce_avatax\Resolver
View source
class ProductVariationTaxCodeResolver implements TaxCodeResolverInterface {

  /**
   * {@inheritdoc}
   */
  public function resolve(OrderItemInterface $order_item) {
    $purchased_entity = $order_item
      ->getPurchasedEntity();
    if ($purchased_entity instanceof ProductVariationInterface) {
      if (!$purchased_entity
        ->get('avatax_tax_code')
        ->isEmpty()) {
        return $purchased_entity
          ->get('avatax_tax_code')->value;
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ProductVariationTaxCodeResolver::resolve public function Resolves the tax code of a given order item.. Overrides TaxCodeResolverInterface::resolve