public function BuildZonesEventSubscriber::onBuildZones in Commerce Core 8.2
Alters the Germany tax rates.
Parameters
\Drupal\commerce_tax\Event\BuildZonesEvent $event: The build zones event.
File
- modules/
tax/ tests/ modules/ commerce_tax_test/ src/ EventSubscriber/ BuildZonesEventSubscriber.php, line 30
Class
- BuildZonesEventSubscriber
- Provides a test event subscriber that alters the Germany tax rates.
Namespace
Drupal\commerce_tax_test\EventSubscriberCode
public function onBuildZones(BuildZonesEvent $event) {
$plugin = $event
->getPlugin();
if ($plugin
->getPluginId() !== 'european_union_vat') {
return;
}
$zones = $event
->getZones();
$germany_zone = $zones['de']
->toArray();
// Add a "fake" standard rate percentage of 25% from January 1st, 2041.
foreach ($germany_zone['rates'] as &$rate) {
if ($rate['id'] !== 'standard') {
continue;
}
$rate['percentages'][] = [
'number' => '0.25',
'start_date' => '2041-01-01',
];
}
$zones['de'] = new TaxZone($germany_zone);
$event
->setZones($zones);
}