You are here

function commerce_tax_form_commerce_order_item_type_form_alter in Commerce Core 8.2

Implements hook_form_FORM_ID_alter() for 'commerce_order_item_type_form'.

File

modules/tax/commerce_tax.module, line 93
Provides tax functionality.

Code

function commerce_tax_form_commerce_order_item_type_form_alter(array &$form, FormStateInterface $form_state) {

  /** @var \Drupal\commerce_order\Entity\OrderTypeInterface $order_item_type */
  $order_item_type = $form_state
    ->getFormObject()
    ->getEntity();
  $form['commerce_tax'] = [
    '#type' => 'container',
    '#weight' => 5,
  ];
  $form['commerce_tax']['taxable_type'] = [
    '#type' => 'select',
    '#title' => t('Taxable type'),
    '#options' => TaxableType::getLabels(),
    '#default_value' => $order_item_type
      ->getThirdPartySetting('commerce_tax', 'taxable_type', TaxableType::getDefault()),
    '#required' => TRUE,
  ];
  $form['actions']['submit']['#submit'][] = 'commerce_tax_order_item_type_form_submit';
}