uc_payment.rules_defaults.inc 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * @file
  4. * Default rules configurations.
  5. */
  6. /**
  7. * Implements hook_default_rules_configuration().
  8. */
  9. function uc_payment_default_rules_configuration() {
  10. $configs = array();
  11. // Set the order status to "Payment Received" when a payment is received
  12. // and the balance is less than or equal to 0.
  13. $rule = rules_reaction_rule();
  14. $rule->label = t('Update order status on full payment');
  15. $rule->active = TRUE;
  16. $rule->event('uc_payment_entered')
  17. ->condition('uc_payment_condition_order_balance', array(
  18. 'order:select' => 'order',
  19. 'balance_comparison' => 'less_equal',
  20. ))
  21. ->condition(rules_or()
  22. ->condition('uc_order_condition_order_state', array(
  23. 'order:select' => 'order',
  24. 'order_state' => 'in_checkout',
  25. ))
  26. ->condition('uc_order_condition_order_state', array(
  27. 'order:select' => 'order',
  28. 'order_state' => 'post_checkout',
  29. ))
  30. )
  31. ->action('uc_order_update_status', array(
  32. 'order:select' => 'order',
  33. 'order_status' => 'payment_received',
  34. ));
  35. $configs['uc_payment_received'] = $rule;
  36. // Set the order status to "Completed" when checkout is complete, none
  37. // of the products are shippable, and the balance is less than or equal to 0.
  38. $rule = rules_reaction_rule();
  39. $rule->label = t('Complete non-shippable order after payment received');
  40. $rule->active = TRUE;
  41. $rule->event('uc_order_status_update')
  42. ->condition('data_is', array('data:select' => 'updated_order:order-status', 'value' => 'payment_received'))
  43. ->condition(rules_condition('uc_order_condition_is_shippable', array(
  44. 'order:select' => 'updated_order',
  45. ))
  46. ->negate())
  47. ->action('uc_order_update_status', array(
  48. 'order:select' => 'order',
  49. 'order_status' => 'completed',
  50. ));
  51. $configs['uc_checkout_complete_paid'] = $rule;
  52. $methods = _uc_payment_method_list();
  53. foreach ($methods as $id => $method) {
  54. $set = rules_and(array(
  55. 'order' => array('type' => 'uc_order', 'label' => t('Order')),
  56. ));
  57. $set->label = t('@method conditions', array('@method' => $method['name']));
  58. $configs['uc_payment_method_' . $method['id']] = $set;
  59. }
  60. return $configs;
  61. }