public function StoreTax::getDefaultTaxType in Commerce Core 8.2
Gets the default tax type for the given store.
Parameters
\Drupal\commerce_store\Entity\StoreInterface $store: The store.
Return value
\Drupal\commerce_tax\Entity\TaxTypeInterface|null The default tax type, or NULL if none apply.
Overrides StoreTaxInterface::getDefaultTaxType
2 calls to StoreTax::getDefaultTaxType()
- StoreTax::getDefaultRates in modules/
tax/ src/ StoreTax.php - Gets the default tax rates for the given store and order item.
- StoreTax::getDefaultZones in modules/
tax/ src/ StoreTax.php - Gets the default tax zones for the given store.
File
- modules/
tax/ src/ StoreTax.php, line 65
Class
Namespace
Drupal\commerce_taxCode
public function getDefaultTaxType(StoreInterface $store) {
$store_id = $store
->id();
if (!array_key_exists($store_id, $this->storeTaxTypes)) {
$store_address = $store
->getAddress();
$tax_types = $this
->getTaxTypes();
$this->storeTaxTypes[$store_id] = NULL;
foreach ($tax_types as $tax_type) {
/** @var \Drupal\commerce_tax\Plugin\Commerce\TaxType\LocalTaxTypeInterface $tax_type_plugin */
$tax_type_plugin = $tax_type
->getPlugin();
$matching_zones = $tax_type_plugin
->getMatchingZones($store_address);
if ($matching_zones) {
$this->storeTaxTypes[$store_id] = $tax_type;
break;
}
}
}
return $this->storeTaxTypes[$store_id];
}