1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Provides metadata for the order entity.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Implements hook_entity_property_info().
|
10 |
|
|
*/
|
11 |
|
|
function commerce_order_entity_property_info() {
|
12 |
|
|
$info = array();
|
13 |
|
|
|
14 |
|
|
// Add meta-data about the basic commerce_order properties.
|
15 |
|
|
$properties = &$info['commerce_order']['properties'];
|
16 |
|
|
|
17 |
|
|
$properties['order_id'] = array(
|
18 |
|
|
'type' => 'integer',
|
19 |
|
|
'label' => t('Order ID', array(), array('context' => 'a drupal commerce order')),
|
20 |
|
|
'description' => t('The internal numeric ID of the order.'),
|
21 |
|
|
'schema field' => 'order_id',
|
22 |
|
|
);
|
23 |
|
|
$properties['order_number'] = array(
|
24 |
|
|
'type' => 'text',
|
25 |
|
|
'label' => t('Order number', array(), array('context' => 'a drupal commerce order')),
|
26 |
|
|
'description' => t('The order number displayed to the customer.'),
|
27 |
|
|
'setter callback' => 'entity_property_verbatim_set',
|
28 |
|
|
'schema field' => 'order_number',
|
29 |
|
|
);
|
30 |
|
|
$properties['status'] = array(
|
31 |
|
|
'type' => 'text',
|
32 |
|
|
'label' => t('Status'),
|
33 |
|
|
'description' => t('The current status of the order.'),
|
34 |
|
|
'setter callback' => 'entity_property_verbatim_set',
|
35 |
|
|
'options list' => 'commerce_order_status_options_list',
|
36 |
|
|
'required' => TRUE,
|
37 |
|
|
'schema field' => 'status',
|
38 |
|
|
);
|
39 |
|
|
$properties['state'] = array(
|
40 |
|
|
'type' => 'token',
|
41 |
|
|
'label' => t('State'),
|
42 |
|
|
'description' => t('The state of the order derived from its status.'),
|
43 |
|
|
'getter callback' => 'commerce_order_get_properties',
|
44 |
|
|
'options list' => 'commerce_order_state_options_list',
|
45 |
|
|
'computed' => TRUE,
|
46 |
|
|
);
|
47 |
|
|
$properties['created'] = array(
|
48 |
|
|
'type' => 'date',
|
49 |
|
|
'label' => t('Date created'),
|
50 |
|
|
'description' => t('The date the order was created.'),
|
51 |
|
|
'setter callback' => 'entity_property_verbatim_set',
|
52 |
|
|
'setter permission' => 'administer commerce_order entities',
|
53 |
|
|
'schema field' => 'created',
|
54 |
|
|
);
|
55 |
|
|
$properties['changed'] = array(
|
56 |
|
|
'type' => 'date',
|
57 |
|
|
'label' => t('Date changed'),
|
58 |
|
|
'description' => t('The date the order was most recently updated.'),
|
59 |
|
|
'setter callback' => 'entity_property_verbatim_set',
|
60 |
|
|
'setter permission' => 'administer commerce_order entities',
|
61 |
|
|
'schema field' => 'changed',
|
62 |
|
|
);
|
63 |
|
|
$properties['hostname'] = array(
|
64 |
|
|
'type' => 'text',
|
65 |
|
|
'label' => t('Host name'),
|
66 |
|
|
'description' => t('The IP address that created this order.'),
|
67 |
|
|
'setter callback' => 'entity_property_verbatim_set',
|
68 |
|
|
'setter permission' => 'administer commerce_order entities',
|
69 |
|
|
'schema field' => 'hostname',
|
70 |
|
|
);
|
71 |
|
|
$properties['type'] = array(
|
72 |
|
|
'type' => 'text',
|
73 |
|
|
'label' => t('Type'),
|
74 |
|
|
'description' => t('The human readable name of the order type.'),
|
75 |
|
|
'setter callback' => 'entity_property_verbatim_set',
|
76 |
|
|
'options list' => 'commerce_order_type_options_list',
|
77 |
|
|
'required' => TRUE,
|
78 |
|
|
'schema field' => 'type',
|
79 |
|
|
);
|
80 |
|
|
$properties['uid'] = array(
|
81 |
|
|
'type' => 'integer',
|
82 |
|
|
'label' => t("Owner ID"),
|
83 |
|
|
'description' => t("The unique ID of the order owner."),
|
84 |
|
|
'setter callback' => 'entity_property_verbatim_set',
|
85 |
|
|
'setter permission' => 'administer commerce_order entities',
|
86 |
|
|
'clear' => array('owner'),
|
87 |
|
|
'schema field' => 'uid',
|
88 |
|
|
);
|
89 |
|
|
$properties['owner'] = array(
|
90 |
|
|
'type' => 'user',
|
91 |
|
|
'label' => t("Owner"),
|
92 |
|
|
'description' => t("The owner of the order."),
|
93 |
|
|
'getter callback' => 'commerce_order_get_properties',
|
94 |
|
|
'setter callback' => 'commerce_order_set_properties',
|
95 |
|
|
'setter permission' => 'administer commerce_order entities',
|
96 |
|
|
'required' => TRUE,
|
97 |
|
|
'computed' => TRUE,
|
98 |
|
|
'clear' => array('uid'),
|
99 |
|
|
);
|
100 |
|
|
$properties['mail'] = array(
|
101 |
|
|
'label' => t('Order e-mail'),
|
102 |
|
|
'description' => t('The e-mail address associated with this order.'),
|
103 |
|
|
'setter callback' => 'entity_property_verbatim_set',
|
104 |
|
|
'validation callback' => 'valid_email_address',
|
105 |
|
|
'schema field' => 'mail',
|
106 |
|
|
);
|
107 |
|
|
$properties['mail_username'] = array(
|
108 |
|
|
'type' => 'text',
|
109 |
|
|
'label' => t('Order e-mail prepared for username usage'),
|
110 |
|
|
'description' => t('The e-mail address associated with this order with illegal characters for usernames replaced.'),
|
111 |
|
|
'getter callback' => 'commerce_order_get_properties',
|
112 |
|
|
'computed' => TRUE,
|
113 |
|
|
'clear' => array('mail'),
|
114 |
|
|
);
|
115 |
|
|
|
116 |
|
|
return $info;
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
/**
|
120 |
|
|
* Implements hook_entity_property_info_alter() on top of the Order module.
|
121 |
|
|
*/
|
122 |
|
|
function commerce_order_entity_property_info_alter(&$info) {
|
123 |
|
|
// Move the line items and order total properties to the order by default; as
|
124 |
|
|
// they are required default fields, this makes dealing with them more convenient.
|
125 |
|
|
$properties = array();
|
126 |
|
|
|
127 |
|
|
foreach ($info['commerce_order']['bundles'] as $bundle => $bundle_info) {
|
128 |
|
|
$bundle_info += array('properties' => array());
|
129 |
|
|
$properties += $bundle_info['properties'];
|
130 |
|
|
}
|
131 |
|
|
|
132 |
9d13637e
|
Assos Assos
|
if (!empty($properties['commerce_line_items'])) {
|
133 |
|
|
$info['commerce_order']['properties']['commerce_line_items'] = $properties['commerce_line_items'];
|
134 |
|
|
}
|
135 |
|
|
if (!empty($properties['commerce_order_total'])) {
|
136 |
|
|
$info['commerce_order']['properties']['commerce_order_total'] = $properties['commerce_order_total'];
|
137 |
|
|
}
|
138 |
85ad3d82
|
Assos Assos
|
} |