public function Custom::buildZones in Commerce Core 8.2
Builds the tax zones.
Return value
\Drupal\commerce_tax\TaxZone[] The tax zones, keyed by ID.
Overrides LocalTaxTypeBase::buildZones
File
- modules/
tax/ src/ Plugin/ Commerce/ TaxType/ Custom.php, line 379
Class
- Custom
- Provides the Custom tax type.
Namespace
Drupal\commerce_tax\Plugin\Commerce\TaxTypeCode
public function buildZones() {
$rates = $this->configuration['rates'];
// The plugin doesn't support defining multiple percentages with own
// start/end dates for UX reasons, so a start date is invented here.
foreach ($rates as &$rate) {
$rate['percentages'][] = [
'number' => (string) $rate['percentage'],
'start_date' => '2000-01-01',
];
unset($rate['percentage']);
}
// The first defined rate is assumed to be the default.
$rates[0]['default'] = TRUE;
$zones = [];
$zones['default'] = new TaxZone([
'id' => 'default',
'label' => 'Default',
'display_label' => $this
->getDisplayLabel(),
'territories' => $this->configuration['territories'],
'rates' => $rates,
]);
return $zones;
}