uc_stock.rules.inc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * @file
  4. * Rules hooks for uc_stock.module.
  5. */
  6. /**
  7. * Implements hook_rules_action_info().
  8. */
  9. function uc_stock_rules_action_info() {
  10. $actions['uc_stock_action_decrement_stock'] = array(
  11. 'label' => t('Decrement stock of products on the order with tracking activated.'),
  12. 'group' => t('Stock'),
  13. 'base' => 'uc_stock_action_decrement_stock',
  14. 'parameter' => array(
  15. 'order' => array(
  16. 'type' => 'uc_order',
  17. 'label' => t('Order'),
  18. ),
  19. ),
  20. );
  21. $actions['uc_stock_action_increment_stock'] = array(
  22. 'label' => t('Increment stock of products on the order with tracking activated.'),
  23. 'group' => t('Stock'),
  24. 'base' => 'uc_stock_action_increment_stock',
  25. 'parameter' => array(
  26. 'order' => array(
  27. 'type' => 'uc_order',
  28. 'label' => t('Order'),
  29. ),
  30. ),
  31. );
  32. return $actions;
  33. }
  34. /**
  35. * Decreases the stock of ordered products.
  36. */
  37. function uc_stock_action_decrement_stock($order) {
  38. if (is_array($order->products)) {
  39. array_walk($order->products, 'uc_stock_adjust_product_stock', $order);
  40. }
  41. }
  42. /**
  43. * Increase the stock of ordered products.
  44. */
  45. function uc_stock_action_increment_stock($order, $settings) {
  46. if (is_array($order->products)) {
  47. array_walk($order->products, 'uc_stock_increment_product_stock', $order);
  48. }
  49. }