-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommerce_instamojo.install
57 lines (52 loc) · 1.37 KB
/
commerce_instamojo.install
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* Implements hook_install().
*
* Creates some default entries on this module custom table.
*
* @see hook_install()
*
* @ingroup lotus
*/
function commerce_instamojo_install() {
$database = \Drupal::database();
// Add a default entry.
if (!field_info_field('field')) {
$field = array(
'field_name' => 'field_phone_no',
'type' => 'text',
'cardinality' => 1,
);
field_create_field($field);
// Create the instance on the bundle.
$instance = array(
'field_name' => 'field_phone_no',
'entity_type' => 'commerce_customer_profile',
'label' => 'Phone no.',
'bundle' => 'billing',
// If you don't set the "required" property then the field wont be
// required by default.
'required' => TRUE,
'settings' => array(
// Here you inform either or not you want this field showing up on
// the registration form.
// 'user_register_form' => 1,
),
'widget' => array(
'type' => 'textfield',
'weight' => '1',
),
);
field_create_instance($instance);
}
}
/**
* Implements hook_uninstall().
*/
function commerce_instamojo_uninstall() {
// Delete fields when module uninstall.
$bundle_fields = \Drupal::getContainer()->get('commerce_customer_profile')->getFieldDefinitions($entity_type, $bundle);
$field_definition = $bundle_fields[$field_phone_no];
$catalog_id = $field_definition->getSetting($billing);
}
?>