protected function TaxRateDefaultWidget::isAllowed in Commerce Product Tax 8
Checks whether the given tax type and zone are allowed in the widget.
Parameters
\Drupal\commerce_tax\Entity\TaxTypeInterface $tax_type: The tax type.
\Drupal\commerce_tax\TaxZone $zone: The tax zone.
Return value
bool TRUE if the given tax type and zone are allowed, FALSE otherwise.
1 call to TaxRateDefaultWidget::isAllowed()
- TaxRateDefaultWidget::getOptions in src/
Plugin/ Field/ FieldWidget/ TaxRateDefaultWidget.php - Returns the array of options for the widget.
File
- src/
Plugin/ Field/ FieldWidget/ TaxRateDefaultWidget.php, line 91
Class
- TaxRateDefaultWidget
- Plugin implementation of the 'commerce_tax_rate_default' widget.
Namespace
Drupal\commerce_product_tax\Plugin\Field\FieldWidgetCode
protected function isAllowed(TaxTypeInterface $tax_type, TaxZone $zone) {
if ($tax_type
->getPluginId() == 'european_union_vat' && $zone
->getId() == 'ic') {
// The EU Intra-Community Supply zone is special and never displayed.
return FALSE;
}
$allowed_zones = $this
->getFieldSetting('allowed_zones');
if (empty($allowed_zones)) {
return TRUE;
}
return in_array($zone
->getId(), $allowed_zones);
}