uc_cart.views.inc 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /**
  3. * @file
  4. * Views hooks.
  5. */
  6. /**
  7. * Implements hook_views_data().
  8. */
  9. function uc_cart_views_data() {
  10. // Cart items table.
  11. $data['uc_cart_products']['table']['group'] = t('Cart item');
  12. $data['uc_cart_products']['table']['base'] = array(
  13. 'field' => 'cart_item_id',
  14. 'title' => t('Cart items'),
  15. 'help' => t('Products in customer carts.'),
  16. );
  17. // Pull in node fields directly.
  18. $data['node']['table']['join']['uc_cart_products'] = array(
  19. 'left_field' => 'nid',
  20. 'field' => 'nid',
  21. );
  22. $data['uc_cart_products']['nid'] = array(
  23. 'title' => t('Nid'),
  24. 'help' => t('The node ID of a product in the cart.'),
  25. 'field' => array(
  26. 'handler' => 'views_handler_field_node',
  27. 'click sortable' => TRUE,
  28. ),
  29. 'argument' => array(
  30. 'handler' => 'views_handler_argument_node_nid',
  31. 'name field' => 'title',
  32. 'numeric' => TRUE,
  33. 'validate type' => 'nid',
  34. ),
  35. 'sort' => array(
  36. 'handler' => 'views_handler_sort',
  37. ),
  38. 'filter' => array(
  39. 'handler' => 'views_handler_filter_numeric',
  40. ),
  41. );
  42. $data['uc_cart_products']['cart_id'] = array(
  43. 'title' => t('Cart ID'),
  44. 'help' => t('The ID of the cart (user ID for authenticated users, session ID for anonymous users).'),
  45. 'field' => array(
  46. 'handler' => 'uc_cart_handler_field_cart_user',
  47. 'click sortable' => TRUE,
  48. ),
  49. 'argument' => array(
  50. 'handler' => 'views_handler_argument_user_uid',
  51. 'name field' => 'name',
  52. 'numeric' => TRUE,
  53. 'validate type' => 'cart_id',
  54. ),
  55. 'sort' => array(
  56. 'handler' => 'views_handler_sort',
  57. ),
  58. 'filter' => array(
  59. 'handler' => 'views_handler_filter_numeric',
  60. ),
  61. );
  62. $data['uc_cart_products']['qty'] = array(
  63. 'title' => t('Quantity'),
  64. 'help' => t('The quantity to be ordered.'),
  65. 'field' => array(
  66. 'handler' => 'views_handler_field_numeric',
  67. 'click sortable' => TRUE,
  68. ),
  69. 'sort' => array(
  70. 'handler' => 'views_handler_sort',
  71. ),
  72. 'filter' => array(
  73. 'handler' => 'views_handler_filter_numeric',
  74. ),
  75. );
  76. $data['uc_cart_products']['changed'] = array(
  77. 'title' => t('Last modified'),
  78. 'help' => t('The time the cart item was last modified'),
  79. 'field' => array(
  80. 'handler' => 'views_handler_field_date',
  81. 'click sortable' => TRUE,
  82. ),
  83. 'sort' => array(
  84. 'handler' => 'views_handler_sort_date',
  85. ),
  86. 'filter' => array(
  87. 'handler' => 'views_handler_filter_date',
  88. ),
  89. );
  90. return $data;
  91. }