$order_first_name)); ?>
- --
-
diff --git a/uc_order/uc_order.ca.inc b/uc_order/uc_order.ca.inc
index 5d7f4a0..1afd16c 100644
--- a/uc_order/uc_order.ca.inc
+++ b/uc_order/uc_order.ca.inc
@@ -128,6 +128,16 @@ function uc_order_ca_condition() {
),
);
+ $conditions['uc_order_state_condition'] = array(
+ '#title' => t('Check the order state'),
+ '#description' => t('Returns TRUE if the current order status belong to the order state specified below.'),
+ '#category' => t('Order'),
+ '#callback' => 'uc_order_condition_check_order_state',
+ '#arguments' => array(
+ 'order' => $order_arg,
+ ),
+ );
+
$conditions['uc_order_condition_total'] = array(
'#title' => t('Check the order total'),
'#description' => t('Returns TRUE if the current order total is within the parameters below.'),
@@ -368,6 +378,36 @@ function uc_order_condition_check_order_status_form($form_state, $settings = arr
}
/**
+ * Check the current order state.
+ *
+ * @see uc_order_condition_check_order_state_form()
+ */
+function uc_order_condition_check_order_state($order, $settings) {
+ // Return TRUE if the order status matches.
+ return uc_order_status_data($order->order_status, 'state') == $settings['order_state'];
+}
+
+/**
+ * @see uc_order_condition_check_order_state()
+ */
+function uc_order_condition_check_order_state_form($form_state, $settings = array()) {
+ foreach (uc_order_state_list('general') as $state) {
+ $options[$state['id']] = $state['title'];
+ }
+ foreach (uc_order_state_list('specific') as $state) {
+ $options[$state['id']] = $state['title'];
+ }
+ $form['order_state'] = array(
+ '#type' => 'select',
+ '#title' => t('Order state'),
+ '#options' => $options,
+ '#default_value' => $settings['order_state'],
+ );
+
+ return $form;
+}
+
+/**
* Check the current order balance.
*
* @see uc_order_condition_total_form()
diff --git a/uc_order/uc_order.module b/uc_order/uc_order.module
index 3fdf9b0..2836bf6 100644
--- a/uc_order/uc_order.module
+++ b/uc_order/uc_order.module
@@ -414,13 +414,11 @@ function uc_order_token_values($type, $object = NULL) {
case 'order':
$order = $object;
- if (isset($_SESSION['new_user']) && is_array($_SESSION['new_user'])) {
- $values['new-username'] = check_plain($_SESSION['new_user']['name']);
- $values['new-password'] = check_plain($_SESSION['new_user']['pass']);
+ if (isset($order->data['new_user']['name'])) {
+ $values['new-username'] = $order->data['new_user']['name'];
}
else {
$values['new-username'] = '';
- $values['new-password'] = '';
}
$values['order-id'] = $order->order_id;
$values['order-uid'] = $order->uid;
@@ -492,7 +490,6 @@ function uc_order_token_list($type = 'all') {
if ($type == 'order' || $type == 'ubercart' || $type == 'all') {
$tokens['order']['new-username'] = t('New username associated with an order if applicable.');
- $tokens['order']['new-password'] = t('New password associated with an order if applicable.');
$tokens['order']['order-id'] = t('The order ID.');
$tokens['order']['order-uid'] = t('The user ID of the order.');
$tokens['order']['order-url'] = t('The URL to the order');
@@ -1347,7 +1344,12 @@ function uc_order_update_status($order_id, $status) {
// Attempt the update if the order exists.
if ($order !== FALSE) {
- // Return false if any module says the update is not good to go.
+ // Return TRUE if the order status is already set.
+ if ($order->order_status == $status) {
+ return TRUE;
+ }
+
+ // Return FALSE if any module says the update is not good to go.
foreach (module_list() as $module) {
$function = $module .'_order';
// $order must be passed by reference.
diff --git a/uc_roles/uc_roles.ca.inc b/uc_roles/uc_roles.ca.inc
index 749703f..653f4d3 100644
--- a/uc_roles/uc_roles.ca.inc
+++ b/uc_roles/uc_roles.ca.inc
@@ -44,23 +44,12 @@ function uc_roles_ca_predicate() {
'#conditions' => array(
array(
'#name' => 'uc_order_status_condition',
- '#title' => t('If the original order status was not Completed.'),
- '#argument_map' => array(
- 'order' => 'order',
- ),
- '#settings' => array(
- 'negate' => TRUE,
- 'order_status' => 'completed',
- ),
- ),
- array(
- '#name' => 'uc_order_status_condition',
- '#title' => t('If the updated order status is Completed.'),
+ '#title' => t('If the updated order status is payment received.'),
'#argument_map' => array(
'order' => 'updated_order',
),
'#settings' => array(
- 'order_status' => 'completed',
+ 'order_status' => 'payment_received',
),
),
),