-
Notifications
You must be signed in to change notification settings - Fork 1
/
commerce_giftcard.module
39 lines (34 loc) · 1.11 KB
/
commerce_giftcard.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/**
* @file
* Primary module hooks for Commerce Gift Card module.
*/
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
/**
* Implements hook_entity_base_field_info().
*/
function commerce_giftcard_entity_base_field_info(EntityTypeInterface $entity_type) {
if ($entity_type->id() == 'commerce_order') {
$fields['commerce_giftcards'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Giftcards'))
->setDescription(t('Giftcards which have been applied to order.'))
->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED)
->setRequired(FALSE)
->setSetting('target_type', 'commerce_giftcard')
->setSetting('handler', 'default')
->setTranslatable(FALSE)
->addConstraint('GiftcardOrderCurrency')
->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => 5,
'settings' => [
'match_operator' => 'CONTAINS',
'size' => '60',
'autocomplete_type' => 'tags',
'placeholder' => '',
],
]);
return $fields;
}
}