-
Notifications
You must be signed in to change notification settings - Fork 7
/
commerce_behat.install
94 lines (84 loc) · 2.65 KB
/
commerce_behat.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/**
* @file
* Install, update and uninstall functions for the Commerce deploy installation profile.
*/
/**
* Implements hook_install().
*/
function commerce_behat_install() {
// Provide default country for Addressfield to default on.
variable_set('site_default_country', 'US');
$instance = field_info_instance('commerce_customer_profile', 'commerce_customer_address', 'billing');
$instance['widget']['settings']['default_country'] = 'US';
// Generate a product display content type
$behat_product_display = array(
'type' => 'behat_behat_product_display',
'name' => st('Product display'),
'base' => 'node_content',
'description' => st('Use product displays for adding product pages to your store'),
'custom' => 1,
'modified' => 1,
'locked' => 0,
);
$behat_product_display = node_type_set_defaults($behat_product_display);
node_type_save($behat_product_display);
node_add_body_field($behat_product_display);
// Add a product reference field that uses Inline Entity Form.
// This field name changed early in development.
// See https://www.drupal.org/node/2298111.
$field_name = 'field_product';
$entity_type = 'node';
$bundle = 'behat_product_display';
$label = 'Products';
commerce_activate_field($field_name);
field_cache_clear();
$field = field_info_field($field_name);
$instance = field_info_instance($entity_type, $field_name, $bundle);
if (empty($field)) {
$field = array(
'field_name' => $field_name,
'type' => 'commerce_product_reference',
'cardinality' => -1,
'entity_types' => array($entity_type),
'translatable' => FALSE,
'locked' => FALSE,
);
$field = field_create_field($field);
}
if (empty($instance)) {
$instance = array(
'field_name' => $field_name,
'entity_type' => $entity_type,
'bundle' => $bundle,
'label' => $label,
'required' => TRUE,
'settings' => array(),
'widget' => array(
'type' => 'inline_entity_form',
'weight' => 0,
'settings' => array(
'type_settings' => array(
'allow_bulk_create' => 1,
),
),
),
'display' => array(
'display' => array(
'label' => 'hidden',
'weight' => 5,
'type' => 'commerce_cart_add_to_cart_form',
'settings' => array(
'show_quantity' => FALSE,
'default_quantity' => 1,
'combine' => TRUE,
'show_single_product_attributes' => FALSE,
'line_item_type' => 'product',
),
'module' => 'commerce_cart',
),
),
);
field_create_instance($instance);
}
}