uc_cart.rules_defaults.inc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * @file
  4. * Default Rules configurations.
  5. */
  6. /**
  7. * Implements hook_default_rules_configuration().
  8. */
  9. function uc_cart_default_rules_configuration() {
  10. // Setup an example rule for limiting product quantities.
  11. $rule = rules_reaction_rule();
  12. $rule->label = t('Maximum product quantity');
  13. $rule->active = FALSE;
  14. $rule->event('uc_cart_item_presave')
  15. ->condition('data_is', array(
  16. 'data:select' => 'uc-cart-item:qty',
  17. 'op' => '>',
  18. 'value' => '10',
  19. ))
  20. ->action('data_set', array(
  21. 'data:select' => 'uc-cart-item:qty',
  22. 'value' => '10',
  23. ))
  24. ->action('drupal_message', array(
  25. 'message' => 'You are only allowed to order a maximum of 10 of [uc-cart-item:node:title].',
  26. 'type' => 'warning',
  27. ));
  28. $configs['uc_cart_maximum_product_qty'] = $rule;
  29. // Setup a default configuration for customer checkout notifications.
  30. $rule = rules_reaction_rule();
  31. $rule->label = t('E-mail customer checkout notification');
  32. $rule->active = TRUE;
  33. $rule->event('uc_checkout_complete')
  34. ->action('uc_order_email_invoice', array(
  35. 'order:select' => 'order',
  36. 'from' => uc_store_email_from(),
  37. 'addresses' => '[order:email]',
  38. 'subject' => t('Your Order at [store:name]'),
  39. 'template' => 'customer',
  40. 'view' => 'checkout-mail',
  41. ));
  42. $configs['uc_checkout_customer_notification'] = $rule;
  43. // Setup a default predicate for admin checkout notifications.
  44. $rule = rules_reaction_rule();
  45. $rule->label = t('E-mail admin checkout notification');
  46. $rule->active = TRUE;
  47. $rule->event('uc_checkout_complete')
  48. ->action('uc_order_email_invoice', array(
  49. 'order:select' => 'order',
  50. 'from' => uc_store_email_from(),
  51. 'addresses' => uc_store_email(),
  52. 'subject' => t('New Order at [store:name]'),
  53. 'template' => 'admin',
  54. 'view' => 'admin-mail',
  55. ));
  56. $configs['uc_checkout_admin_notification'] = $rule;
  57. return $configs;
  58. }