Skip to content

Instantly share code, notes, and snippets.

@ozin7
Last active March 20, 2020 07:46
Show Gist options
  • Select an option

  • Save ozin7/ac5ce2d297c870f27b5d3e7d80a20cd3 to your computer and use it in GitHub Desktop.

Select an option

Save ozin7/ac5ce2d297c870f27b5d3e7d80a20cd3 to your computer and use it in GitHub Desktop.
Drupal 8: Commerce condition form element.
<?php
/**
* Implements hook_form_alter().
*/
function HOOK_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if (in_array($form_id, ['commerce_tax_type_edit_form', 'commerce_tax_type_add_form'])) {
$form['commerce_conditions'] = [
'#type' => 'commerce_conditions',
'#title' => t('Conditions'),
'#default_value' => [],
'#parent_entity_type' => 'commerce_tax_type',
'#entity_types' => ['commerce_order_item'],
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment