Projet

Général

Profil

Paste
Télécharger (6,64 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / commerce / modules / order / commerce_order.api.php @ 70a4c29b

1
<?php
2

    
3
/**
4
 * @file
5
 * Hooks provided by the Order module.
6
 */
7

    
8

    
9
/**
10
 * Defines order states for use in grouping order statuses together.
11
 *
12
 * An order state is a particular phase in the life-cycle of an order that is
13
 * comprised of one or more order statuses. In that regard, an order state is
14
 * little more than a container for order statuses with a default status per
15
 * state. This is useful for categorizing orders and advancing orders from one
16
 * state to the next without needing to know the particular status an order will
17
 * end up in.
18
 *
19
 * The Order module defines several order states in its own implementation of
20
 * this hook, commerce_order_commerce_order_state_info():
21
 * - Canceled: for orders that have been canceled through some user action
22
 * - Pending: for orders that have been created and are awaiting further action
23
 * - Completed: for orders that have been completed as far as the customer
24
 *   should be concerned.
25
 *
26
 * Additionally, the Cart and Checkout modules define the following order states:
27
 * - Shopping cart: for orders that have not been completed by the customer yet
28
 * - Checkout: for orders that have begun but not completed the checkout process
29
 *
30
 * The order state array structure is as follows:
31
 * - name: machine-name identifying the order state using lowercase alphanumeric
32
 *   characters, -, and _
33
 * - title: the translatable title of the order state, used in administrative
34
 *   interfaces
35
 * - description: a translatable description of the types of orders that would
36
 *   be in this state
37
 * - weight: integer weight of the state used for sorting lists of order states;
38
 *   defaults to 0
39
 * - default_status: name of the default order status for this state
40
 *
41
 * @return
42
 *   An array of order state arrays keyed by name.
43
 */
44
function hook_commerce_order_state_info() {
45
  $order_states = array();
46

    
47
  $order_states['completed'] = array(
48
    'name' => 'completed',
49
    'title' => t('Completed'),
50
    'description' => t('Orders in this state have been completed as far as the customer is concerned.'),
51
    'weight' => 10,
52
    'default_status' => 'completed',
53
  );
54

    
55
  return $order_states;
56
}
57

    
58
/**
59
 * Allows modules to alter the order state definitions of other modules.
60
 *
61
 * @param $order_states
62
 *   An array of order states defined by enabled modules.
63
 *
64
 * @see hook_commerce_order_state_info()
65
 */
66
function hook_commerce_order_state_info_alter(&$order_states) {
67
  $order_states['completed']['weight'] = 9;
68
}
69

    
70
/**
71
 * Defines order statuses for use in managing orders.
72
 *
73
 * An order status is a single step in the life-cycle of an order that
74
 * administrators can use to know at a glance what has occurred to the order
75
 * already and/or what the next step in processing the order will be.
76
 *
77
 * The Order module defines several order statuses in its own implementation of
78
 * this hook, commerce_order_commerce_order_status_info():
79
 * - Canceled: default status of the Canceled state; used for orders that are
80
 *   marked as canceled via the administrative user interface
81
 * - Pending: default status of the Pending state; used to indicate the order
82
 *   has completed checkout and is awaiting further action before being
83
 *   considered complete
84
 * - Processing: additional status for the Pending state; used to indicate
85
 *   orders that have begun to be processed but are not yet completed
86
 * - Completed: default status of the Completed state; used for orders that
87
 *   don’t require any further attention or customer interaction
88
 *
89
 * The Cart and Checkout modules also define order statuses and interact with
90
 * them in special ways. The Cart module actually uses the order status to
91
 * identify an order as a user’s shopping cart order based on the special
92
 * 'cart' property of order statuses.
93
 *
94
 * The Checkout module uses the order status to determine which page of the
95
 * checkout process a customer is currently on when they go to the checkout URL.
96
 * As the order progresses through checkout, the order status is updated to
97
 * reflect the new page. The statuses defined for these things are as follows:
98
 * - Shopping cart: default status of the Shopping cart state; used for orders
99
 *   that are pure shopping cart orders that have not begun the checkout
100
 *   process at all.
101
 * - Checkout: [page name]: each checkout page has a related order status
102
 *   containing the name of the checkout page the order has progressed to;
103
 *   orders in this status are either in checkout or have been abandoned at the
104
 *   indicated step of the checkout process
105
 *
106
 * The order status array structure is as follows:
107
 * - name: machine-name identifying the order status using lowercase
108
 *   alphanumeric characters, -, and _
109
 * - title: the translatable title of the order status, used in administrative
110
 *   interfaces
111
 * - state: the name of the order state the order status belongs to
112
 * - cart: TRUE or FALSE indicating whether or not orders with this status
113
 *   should be considered shopping cart orders
114
 * - weight: integer weight of the status used for sorting lists of order
115
 *   statuses; defaults to 0
116
 * - status: TRUE or FALSE indicating the enabled status of this order status,
117
 *   with disabled statuses not being available for use; defaults to TRUE
118
 *
119
 * @return
120
 *   An array of order status arrays keyed by name.
121
 */
122
function hook_commerce_order_status_info() {
123
  $order_statuses = array();
124

    
125
  $order_statuses['completed'] = array(
126
    'name' => 'completed',
127
    'title' => t('Completed'),
128
    'state' => 'completed',
129
  );
130

    
131
  return $order_statuses;
132
}
133

    
134
/**
135
 * Allows modules to alter the order status definitions of other modules.
136
 *
137
 * @param $order_statuses
138
 *   An array of order statuses defined by enabled modules.
139
 *
140
 * @see hook_commerce_order_status_info()
141
 */
142
function hook_commerce_order_status_info_alter(&$order_statuses) {
143
  $order_statuses['completed']['title'] = t('Finished');
144
}
145

    
146
/**
147
 * Allows modules to specify a uri for an order.
148
 *
149
 * When this hook is invoked, the first returned uri will be used for the order.
150
 * Thus to override the default value provided by the Order UI module, you would
151
 * need to adjust the order of hook invocation via hook_module_implements_alter()
152
 * or your module weight values.
153
 *
154
 * @param $order
155
 *   The order object whose uri is being determined.
156
 *
157
 * @return
158
 *  The uri elements of an entity as expected to be returned by entity_uri()
159
 *  matching the signature of url().
160
 *
161
 * @see commerce_order_uri()
162
 * @see hook_module_implements_alter()
163
 * @see entity_uri()
164
 * @see url()
165
 */
166
function hook_commerce_order_uri($order) {
167
  // No example.
168
}
169

    
170
/**
171
 * Allows you to prepare order data before it is saved.
172
 *
173
 * @param $order
174
 *   The order object to be saved.
175
 *
176
 * @see rules_invoke_all()
177
 */
178
function hook_commerce_order_presave($order) {
179
  // No example.
180
}