function commerce_avatax_entity_base_field_info in Drupal Commerce Connector for AvaTax 8
Implements hook_entity_base_field_info().
File
- ./
commerce_avatax.module, line 19 - Provides module functionality.
Code
function commerce_avatax_entity_base_field_info(EntityTypeInterface $entity_type) {
$fields = [];
if ($entity_type
->id() === 'commerce_store') {
$fields['avatax_company_code'] = BaseFieldDefinition::create('string')
->setLabel(t('AvaTax company code'))
->setDescription(t('The company code to send to AvaTax when calculating taxes.'))
->setDisplayConfigurable('form', TRUE)
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => 0,
]);
}
if ($entity_type
->id() === 'commerce_product_variation') {
$fields['avatax_tax_code'] = BaseFieldDefinition::create('string')
->setLabel(t('AvaTax tax code'))
->setDescription(t('Browse codes in Avalara\'s <a href="@tax-code-finder" target="_blank">tax code finder</a>.', [
'@tax-code-finder' => 'https://taxcode.avatax.avalara.com',
]))
->setSetting('display_description', TRUE)
->setDisplayConfigurable('form', TRUE)
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => 0,
]);
}
if ($entity_type
->id() === 'user') {
$fields['avatax_customer_code'] = BaseFieldDefinition::create('string')
->setLabel(t('AvaTax customer code'))
->setDisplayConfigurable('form', TRUE)
->setSetting('max_length', 50)
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => 0,
]);
$fields['avatax_tax_exemption_number'] = BaseFieldDefinition::create('string')
->setLabel(t('Tax Exemption number'))
->setDisplayConfigurable('form', TRUE)
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => 0,
]);
$fields['avatax_tax_exemption_type'] = BaseFieldDefinition::create('list_string')
->setLabel(t('Tax Exemption type'))
->setSetting('allowed_values_function', [
'\\Drupal\\commerce_avatax\\Avatax',
'getExemptionTypes',
])
->setDisplayOptions('form', [
'type' => 'options_select',
'weight' => 4,
])
->setDisplayConfigurable('form', TRUE);
}
return $fields;
}