-
Notifications
You must be signed in to change notification settings - Fork 4
/
uc_varprice.install
106 lines (97 loc) · 2.44 KB
/
uc_varprice.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
95
96
97
98
99
100
101
102
103
104
105
106
<?php
/**
* @file
* Installs the necessary table for the Variable Price product features.
*/
/**
* Implementation of hoook_schema()
*/
function uc_varprice_schema() {
$schema = array();
$schema['uc_varprice_products'] = array(
'fields' => array(
'vpid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'pfid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'price_default' => array(
'description' => 'Default product price.',
'type' => 'numeric',
'precision' => 10,
'scale' => 2,
'not null' => TRUE,
'default' => 0.0,
),
'price_minimum' => array(
'description' => 'Minimum product price.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'price_maximum' => array(
'description' => 'Maximum product price.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'add_to_cart_title' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'amount_title' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
),
'indexes' => array(
'pfid' => array('pfid'),
),
'primary key' => array('vpid'),
);
return $schema;
}
/**
* Implements hook_uninstall().
*/
function uc_varprice_uninstall() {
db_delete('uc_product_features')
->condition('fid', 'varprice')
->execute();
}
/**
* Migrate uc_varprice variables to config.
*/
function uc_varprice_update_1000() {
$config = config('uc_varprice.settings');
$config->set('uc_varprice_global_default', update_variable_get('uc_varprice_global_default', '0'));
$config->save();
update_variable_del('uc_varprice_global_default');
}
/**
* Convert product class defaults to config.
*/
function uc_varprice_update_1001() {
foreach (node_type_get_names() as $type => $name) {
$config = config('uc_varprice.settings');
$data = update_variable_get('ucvp_class_def_' . $type);
if (!empty($data)) {
$data = unserialize($data);
}
$config->set('class_definitions.' . $type, $data);
$config->save();
update_variable_del('ucvp_class_def_' . $type);
}
}