function uc_payment_ca_predicate in Ubercart 6.2
Implements hook_ca_predicate().
File
- payment/
uc_payment/ uc_payment.ca.inc, line 17 - This file contains the Conditional Actions hooks and functions necessary to make the order related entity, conditions, events, and actions work.
Code
function uc_payment_ca_predicate() {
$predicates = array();
// Set the order status to "Payment Received" when a payment is received
// and the balance is less than or equal to 0.
$predicates['uc_payment_received'] = array(
'#title' => t('Update order status on full payment'),
'#description' => t('Only happens when a payment is entered and the balance is <= $0.00.'),
'#class' => 'payment',
'#trigger' => 'uc_payment_entered',
'#status' => 1,
'#conditions' => array(
'#operator' => 'AND',
'#conditions' => array(
array(
'#name' => 'uc_payment_condition_order_balance',
'#title' => t('If the balance is less than or equal to $0.00.'),
'#argument_map' => array(
'order' => 'order',
),
'#settings' => array(
'negate' => FALSE,
'balance_comparison' => 'less_equal',
),
),
array(
'#operator' => 'OR',
'#conditions' => array(
array(
'#name' => 'uc_order_state_condition',
'#title' => t('If the order state is in checkout.'),
'#argument_map' => array(
'order' => 'order',
),
'#settings' => array(
'order_state' => 'in_checkout',
),
),
array(
'#name' => 'uc_order_state_condition',
'#title' => t('If the order state is post checkout.'),
'#argument_map' => array(
'order' => 'order',
),
'#settings' => array(
'order_state' => 'post_checkout',
),
),
),
),
),
),
'#actions' => array(
array(
'#name' => 'uc_order_update_status',
'#title' => t('Update the order status to Payment Received.'),
'#argument_map' => array(
'order' => 'order',
),
'#settings' => array(
'order_status' => 'payment_received',
),
),
),
);
// Set the order status to "Completed" when payment has been received
// and none of the products are shippable.
$predicates['uc_checkout_complete_paid'] = array(
'#title' => t('Complete non-shippable order after payment received'),
'#trigger' => 'uc_order_status_update',
'#class' => 'payment',
'#status' => 1,
'#weight' => 1,
'#conditions' => array(
'#operator' => 'AND',
'#conditions' => array(
array(
'#name' => 'uc_order_status_condition',
'#title' => t('If the order status is Payment received.'),
'#argument_map' => array(
'order' => 'updated_order',
),
'#settings' => array(
'order_status' => 'payment_received',
),
),
array(
'#name' => 'uc_order_condition_is_shippable',
'#title' => t('If the order is not shippable.'),
'#argument_map' => array(
'order' => 'updated_order',
),
'#settings' => array(
'negate' => TRUE,
),
),
),
),
'#actions' => array(
array(
'#name' => 'uc_order_update_status',
'#title' => t('Update the order status to Completed.'),
'#argument_map' => array(
'order' => 'updated_order',
),
'#settings' => array(
'order_status' => 'completed',
),
),
),
);
return $predicates;
}