uc_shipping.views.inc 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. <?php
  2. /**
  3. * @file
  4. * Views hooks for Ubercart shipping.
  5. */
  6. /**
  7. * Implements hook_views_data().
  8. */
  9. function uc_shipping_views_data() {
  10. $data['uc_shipments']['table']['group'] = t('Shipment');
  11. // Allow base tables of shipments.
  12. $data['uc_shipments']['table']['base'] = array(
  13. 'field' => 'sid', // This is the identifier field for the view.
  14. 'title' => t('Ubercart shipments'),
  15. 'help' => t('Ubercart shipments contain shipping information for orders and can be related to orders and packages.'),
  16. );
  17. // Shipment relationship for orders.
  18. $data['uc_orders']['shipments'] = array(
  19. 'relationship' => array(
  20. 'title' => t('Shipments'),
  21. 'help' => t('Relate shipments to an order. This relationship will create one record for each shipment.'),
  22. 'handler' => 'views_handler_relationship',
  23. 'base' => 'uc_shipments',
  24. 'base field' => 'order_id',
  25. 'relationship field' => 'order_id',
  26. 'label' => t('shipment'),
  27. ),
  28. );
  29. // Order relationship for shipments.
  30. $data['uc_shipments']['order'] = array(
  31. 'relationship' => array(
  32. 'title' => t('Order'),
  33. 'help' => t('Relate an order to a shipment. Use this relationship to get order information for a shipment.'),
  34. 'handler' => 'views_handler_relationship',
  35. 'base' => 'uc_orders',
  36. 'base field' => 'order_id',
  37. 'relationship field' => 'order_id',
  38. 'label' => t('order'),
  39. ),
  40. );
  41. // Expose packages to their shipments as a relationship.
  42. $data['uc_shipments']['packages'] = array(
  43. 'relationship' => array(
  44. 'title' => t('Packages'),
  45. 'help' => t('Relate packages to a shipment. This relationship will create one record for each shipped package.'),
  46. 'handler' => 'views_handler_relationship',
  47. 'base' => 'uc_packages',
  48. 'base field' => 'sid',
  49. 'relationship field' => 'sid',
  50. 'label' => t('package'),
  51. ),
  52. );
  53. // Shipment ID field.
  54. $data['uc_shipments']['sid'] = array(
  55. 'title' => t('Shipment ID'),
  56. 'help' => t('The shipment ID.'),
  57. 'field' => array(
  58. 'handler' => 'uc_shipping_handler_field_shipment_id',
  59. 'click sortable' => TRUE,
  60. ),
  61. 'sort' => array(
  62. 'handler' => 'views_handler_sort',
  63. ),
  64. 'filter' => array(
  65. 'handler' => 'views_handler_filter_numeric',
  66. ),
  67. 'argument' => array(
  68. 'handler' => 'views_handler_argument_numeric',
  69. 'name field' => 'title',
  70. 'numeric' => TRUE,
  71. 'validate type' => 'sid',
  72. ),
  73. );
  74. // Order ID field.
  75. $data['uc_shipments']['order_id'] = array(
  76. 'title' => t('Order ID'),
  77. 'help' => t('The order ID.'),
  78. 'field' => array(
  79. 'handler' => 'uc_order_handler_field_order_id',
  80. 'click sortable' => TRUE,
  81. ),
  82. 'sort' => array(
  83. 'handler' => 'views_handler_sort',
  84. ),
  85. 'filter' => array(
  86. 'handler' => 'views_handler_filter_numeric',
  87. ),
  88. 'argument' => array(
  89. 'handler' => 'views_handler_argument_numeric',
  90. 'name field' => 'title',
  91. 'numeric' => TRUE,
  92. 'validate type' => 'order_id',
  93. ),
  94. );
  95. // Carrier field.
  96. $data['uc_shipments']['carrier'] = array(
  97. 'title' => t('Carrier'),
  98. 'help' => t('The company making the delivery.'),
  99. 'field' => array(
  100. 'handler' => 'views_handler_field',
  101. 'click sortable' => TRUE,
  102. ),
  103. 'sort' => array(
  104. 'handler' => 'views_handler_sort',
  105. ),
  106. 'filter' => array(
  107. 'handler' => 'views_handler_filter_string',
  108. ),
  109. );
  110. // Shipment transaction ID field.
  111. $data['uc_shipments']['transaction_id'] = array(
  112. 'title' => t('Transaction ID'),
  113. 'help' => t("The carrier's shipment identifier."),
  114. 'field' => array(
  115. 'handler' => 'views_handler_field',
  116. 'click sortable' => TRUE,
  117. ),
  118. 'sort' => array(
  119. 'handler' => 'views_handler_sort',
  120. ),
  121. 'filter' => array(
  122. 'handler' => 'views_handler_filter_string',
  123. ),
  124. 'argument' => array(
  125. 'handler' => 'views_handler_argument_string',
  126. ),
  127. );
  128. // Shipment tracking number field.
  129. $data['uc_shipments']['tracking_number'] = array(
  130. 'title' => t('Tracking number'),
  131. 'help' => t('The number used by the carrier to locate the shipment while it is in transit.'),
  132. 'field' => array(
  133. 'handler' => 'views_handler_field',
  134. 'click sortable' => TRUE,
  135. ),
  136. 'sort' => array(
  137. 'handler' => 'views_handler_sort',
  138. ),
  139. 'filter' => array(
  140. 'handler' => 'views_handler_filter_string',
  141. ),
  142. 'argument' => array(
  143. 'handler' => 'views_handler_argument_string',
  144. ),
  145. );
  146. $data['uc_shipments']['ship_date'] = array(
  147. 'title' => t('Ship date'),
  148. 'help' => t('The date when the shipment left the origin address.'),
  149. 'field' => array(
  150. 'handler' => 'views_handler_field_date',
  151. 'click sortable' => TRUE,
  152. ),
  153. 'sort' => array(
  154. 'handler' => 'views_handler_sort_date',
  155. ),
  156. 'filter' => array(
  157. 'handler' => 'views_handler_filter_date',
  158. ),
  159. );
  160. $data['uc_shipments']['expected_delivery'] = array(
  161. 'title' => t('Expected delivery date'),
  162. 'help' => t('The expected date of delivery.'),
  163. 'field' => array(
  164. 'handler' => 'views_handler_field_date',
  165. 'click sortable' => TRUE,
  166. ),
  167. 'sort' => array(
  168. 'handler' => 'views_handler_sort_date',
  169. ),
  170. 'filter' => array(
  171. 'handler' => 'views_handler_filter_date',
  172. ),
  173. );
  174. $data['uc_shipments']['changed'] = array(
  175. 'title' => t('Last modified'),
  176. 'help' => t('The time the shipment was last modified.'),
  177. 'field' => array(
  178. 'handler' => 'views_handler_field_date',
  179. 'click sortable' => TRUE,
  180. ),
  181. 'sort' => array(
  182. 'handler' => 'views_handler_sort_date',
  183. ),
  184. 'filter' => array(
  185. 'handler' => 'views_handler_filter_date',
  186. ),
  187. );
  188. $data['uc_shipments']['cost'] = array(
  189. 'title' => t('Cost'),
  190. 'help' => t('The cost of the shipment.'),
  191. 'field' => array(
  192. 'handler' => 'uc_order_handler_field_money_amount',
  193. 'click sortable' => TRUE,
  194. 'float' => TRUE,
  195. ),
  196. 'sort' => array(
  197. 'handler' => 'views_handler_sort',
  198. ),
  199. 'filter' => array(
  200. 'handler' => 'views_handler_filter_numeric',
  201. ),
  202. );
  203. $addresses = array(
  204. 'o' => t('Origin address'),
  205. 'd' => t('Delivery address'),
  206. );
  207. $fields = array(
  208. 'first_name' => t('First name'),
  209. 'last_name' => t('Last name'),
  210. 'company' => t('Company'),
  211. 'street1' => t('Street address 1'),
  212. 'street2' => t('Street address 2'),
  213. 'city' => t('City'),
  214. 'postal_code' => t('Postal code'),
  215. );
  216. foreach ($addresses as $prefix => $address) {
  217. $group = t('Shipment') . ': ' . $address;
  218. foreach ($fields as $field => $label) {
  219. $data['uc_shipments'][$prefix . '_' . $field] = array(
  220. 'group' => $group,
  221. 'title' => $label,
  222. 'help' => t('The !field of the !address of the shipment.', array('!field' => drupal_strtolower($label), '!address' => drupal_strtolower($address))),
  223. 'field' => array(
  224. 'handler' => 'views_handler_field',
  225. 'click sortable' => TRUE,
  226. ),
  227. 'sort' => array(
  228. 'handler' => 'views_handler_sort',
  229. ),
  230. 'filter' => array(
  231. 'handler' => 'views_handler_filter_string',
  232. ),
  233. );
  234. }
  235. // uc_order is required by shipping module so is safe to use uc_order handler.
  236. $data['uc_shipments'][$prefix . '_full_name'] = array(
  237. 'group' => $group,
  238. 'title' => t('Full name'),
  239. 'help' => t('The !field of the !address of the shipment.', array('!field' => t('full name'), '!address' => drupal_strtolower($address))),
  240. 'field' => array(
  241. 'additional fields' => array(
  242. $prefix . '_first_name',
  243. $prefix . '_last_name'
  244. ),
  245. 'handler' => 'uc_order_handler_field_order_fullname',
  246. 'prefix' => $prefix,
  247. ),
  248. );
  249. $data['uc_shipments_' . $prefix . '_countries']['table']['group'] = $group;
  250. $data['uc_shipments_' . $prefix . '_countries']['table']['join']['uc_shipments'] = array(
  251. 'table' => 'uc_countries',
  252. 'left_field' => $prefix . '_country',
  253. 'field' => 'country_id',
  254. );
  255. $data['uc_shipments_' . $prefix . '_countries']['country_id'] = array(
  256. 'title' => t('ISO country code (numeric)'),
  257. 'help' => t('The !field of the !address of the shipment.', array('!field' => t('numeric ISO country code'), '!address' => drupal_strtolower($address))),
  258. 'argument' => array(
  259. 'handler' => 'views_handler_argument_numeric',
  260. 'name field' => 'country_iso_code_2',
  261. 'numeric' => TRUE,
  262. 'validate type' => 'country_id',
  263. ),
  264. 'filter' => array(
  265. 'handler' => 'views_handler_filter_numeric',
  266. ),
  267. );
  268. $data['uc_shipments_' . $prefix . '_countries']['country_name'] = array(
  269. 'title' => t('Country'),
  270. 'help' => t('The !field of the !address of the shipment.', array('!field' => t('country name'), '!address' => drupal_strtolower($address))),
  271. 'field' => array(
  272. 'handler' => 'views_handler_field',
  273. 'click sortable' => TRUE,
  274. ),
  275. 'sort' => array(
  276. 'handler' => 'views_handler_sort',
  277. ),
  278. 'filter' => array(
  279. 'handler' => 'views_handler_filter_string',
  280. ),
  281. );
  282. $data['uc_shipments_' . $prefix . '_countries']['country_iso_code_2'] = array(
  283. 'title' => t('ISO country code (2 characters)'),
  284. 'help' => t('The !field of the !address of the shipment.', array('!field' => t('ISO country code'), '!address' => drupal_strtolower($address))),
  285. 'field' => array(
  286. 'handler' => 'views_handler_field',
  287. 'click sortable' => TRUE,
  288. ),
  289. 'sort' => array(
  290. 'handler' => 'views_handler_sort',
  291. ),
  292. 'filter' => array(
  293. 'handler' => 'views_handler_filter_string',
  294. ),
  295. );
  296. $data['uc_shipments_' . $prefix . '_countries']['country_iso_code_3'] = array(
  297. 'title' => t('ISO country code (3 characters)'),
  298. 'help' => t('The !field of the !address of the shipment.', array('!field' => t('ISO country code'), '!address' => drupal_strtolower($address))),
  299. 'field' => array(
  300. 'handler' => 'views_handler_field',
  301. 'click sortable' => TRUE,
  302. ),
  303. 'sort' => array(
  304. 'handler' => 'views_handler_sort',
  305. ),
  306. 'filter' => array(
  307. 'handler' => 'views_handler_filter_string',
  308. ),
  309. );
  310. $data['uc_shipments_' . $prefix . '_zones']['table']['group'] = $group;
  311. $data['uc_shipments_' . $prefix . '_zones']['table']['join']['uc_shipments'] = array(
  312. 'table' => 'uc_zones',
  313. 'left_field' => $prefix . '_zone',
  314. 'field' => 'zone_id',
  315. );
  316. $data['uc_shipments_' . $prefix . '_zones']['zone_name'] = array(
  317. 'title' => t('State/Province'),
  318. 'help' => t('The !field of the !address of the shipment.', array('!field' => t('state or province'), '!address' => drupal_strtolower($address))),
  319. 'field' => array(
  320. 'handler' => 'views_handler_field',
  321. 'click sortable' => TRUE,
  322. ),
  323. 'sort' => array(
  324. 'handler' => 'views_handler_sort',
  325. ),
  326. 'filter' => array(
  327. 'handler' => 'views_handler_filter_string',
  328. ),
  329. );
  330. $data['uc_shipments_' . $prefix . '_zones']['zone_code'] = array(
  331. 'title' => t('State/Province code'),
  332. 'help' => t('The !field of the !address of the shipment.', array('!field' => t('state or province code'), '!address' => drupal_strtolower($address))),
  333. 'field' => array(
  334. 'handler' => 'views_handler_field',
  335. 'click sortable' => TRUE,
  336. ),
  337. 'sort' => array(
  338. 'handler' => 'views_handler_sort',
  339. ),
  340. 'filter' => array(
  341. 'handler' => 'views_handler_filter_string',
  342. ),
  343. );
  344. }
  345. // Expose packages.
  346. $data['uc_packages']['table']['group'] = t('Package');
  347. // Allow base tables of packages.
  348. $data['uc_packages']['table']['base'] = array(
  349. 'field' => 'sid', // This is the identifier field for the view.
  350. 'title' => t('Ubercart packages'),
  351. 'help' => t('Ubercart packages contain physical characteristics, tracking, and label information. They can be related to their orders, shipments, and contents.'),
  352. );
  353. // Expose packages to their order as a relationship.
  354. // Packages can exists without a shipment so this relationship may be useful.
  355. $data['uc_orders']['packages'] = array(
  356. 'relationship' => array(
  357. 'title' => t('Packages'),
  358. 'help' => t('Relate packages to an order. This relationship will create one record for each package of an order.'),
  359. 'handler' => 'views_handler_relationship',
  360. 'base' => 'uc_packages',
  361. 'base field' => 'order_id',
  362. 'relationship field' => 'order_id',
  363. 'label' => t('package'),
  364. ),
  365. );
  366. // Order relationship for packages.
  367. $data['uc_packages']['order'] = array(
  368. 'relationship' => array(
  369. 'title' => t('Order'),
  370. 'help' => t('Relate an order to a package. Use this relationship to get order information for a package.'),
  371. 'handler' => 'views_handler_relationship',
  372. 'base' => 'uc_orders',
  373. 'base field' => 'order_id',
  374. 'relationship field' => 'order_id',
  375. 'label' => t('order'),
  376. ),
  377. );
  378. // Expose packaged products to their package as a relationship.
  379. $data['uc_packages']['packaged_products'] = array(
  380. 'relationship' => array(
  381. 'title' => t('Products'),
  382. 'help' => t('Relate packaged products to a package. This relationship will create one record for each packaged product.'),
  383. 'handler' => 'views_handler_relationship',
  384. 'base' => 'uc_packaged_products',
  385. 'base field' => 'package_id',
  386. 'relationship field' => 'package_id',
  387. 'label' => t('product'),
  388. ),
  389. );
  390. // Expose shipments to their packages as a relationship.
  391. $data['uc_packages']['shipment'] = array(
  392. 'relationship' => array(
  393. 'title' => t('Shipment'),
  394. 'help' => t('Relate shipment to package. Use this relationship to get shipping information for the package. Note that this relationship might not exist.'),
  395. 'handler' => 'views_handler_relationship',
  396. 'base' => 'uc_shipments',
  397. 'base field' => 'sid',
  398. 'relationship field' => 'sid',
  399. 'label' => t('shipment'),
  400. ),
  401. );
  402. // Package ID field.
  403. // We don't redirect to the shipment page because a package can exist without a shipment.
  404. $data['uc_packages']['package_id'] = array(
  405. 'title' => t('Package ID'),
  406. 'help' => t('The package ID.'),
  407. 'field' => array(
  408. 'handler' => 'views_handler_field',
  409. 'click sortable' => TRUE,
  410. ),
  411. 'sort' => array(
  412. 'handler' => 'views_handler_sort',
  413. ),
  414. 'filter' => array(
  415. 'handler' => 'views_handler_filter_numeric',
  416. ),
  417. 'argument' => array(
  418. 'handler' => 'views_handler_argument_numeric',
  419. 'name field' => 'title',
  420. 'numeric' => TRUE,
  421. 'validate type' => 'sid',
  422. ),
  423. );
  424. // Shipment ID field.
  425. $data['uc_packages']['sid'] = array(
  426. 'title' => t('Shipment ID'),
  427. 'help' => t('The shipment ID.'),
  428. 'field' => array(
  429. 'handler' => 'uc_shipping_handler_field_shipment_id',
  430. 'click sortable' => TRUE,
  431. ),
  432. 'sort' => array(
  433. 'handler' => 'views_handler_sort',
  434. ),
  435. 'filter' => array(
  436. 'handler' => 'views_handler_filter_numeric',
  437. ),
  438. 'argument' => array(
  439. 'handler' => 'views_handler_argument_numeric',
  440. 'name field' => 'title',
  441. 'numeric' => TRUE,
  442. 'validate type' => 'sid',
  443. ),
  444. );
  445. // Order ID field.
  446. $data['uc_packages']['order_id'] = array(
  447. 'title' => t('Order ID'),
  448. 'help' => t('The order ID.'),
  449. 'field' => array(
  450. 'handler' => 'uc_order_handler_field_order_id',
  451. 'click sortable' => TRUE,
  452. ),
  453. 'sort' => array(
  454. 'handler' => 'views_handler_sort',
  455. ),
  456. 'filter' => array(
  457. 'handler' => 'views_handler_filter_numeric',
  458. ),
  459. 'argument' => array(
  460. 'handler' => 'views_handler_argument_numeric',
  461. 'name field' => 'title',
  462. 'numeric' => TRUE,
  463. 'validate type' => 'order_id',
  464. ),
  465. );
  466. // Shipment type field.
  467. $data['uc_packages']['shipping_type'] = array(
  468. 'title' => t('Shipment type'),
  469. 'help' => t('The basic type of shipment, e.g.: small package, freight, etc.'),
  470. 'field' => array(
  471. 'handler' => 'views_handler_field',
  472. 'click sortable' => TRUE,
  473. ),
  474. 'sort' => array(
  475. 'handler' => 'views_handler_sort',
  476. ),
  477. 'filter' => array(
  478. 'handler' => 'views_handler_filter_string',
  479. ),
  480. );
  481. // Package type.
  482. $data['uc_packages']['pkg_type'] = array(
  483. 'title' => t('Package type'),
  484. 'help' => t('The type of packaging.'),
  485. 'field' => array(
  486. 'handler' => 'views_handler_field',
  487. 'click sortable' => TRUE,
  488. ),
  489. 'sort' => array(
  490. 'handler' => 'views_handler_sort',
  491. ),
  492. 'filter' => array(
  493. 'handler' => 'views_handler_filter_string',
  494. ),
  495. );
  496. // Package value.
  497. $data['uc_packages']['value'] = array(
  498. 'title' => t('Value'),
  499. 'help' => t('The monetary value of the package contents.'),
  500. 'field' => array(
  501. 'handler' => 'uc_order_handler_field_money_amount',
  502. 'click sortable' => TRUE,
  503. 'float' => TRUE,
  504. ),
  505. 'sort' => array(
  506. 'handler' => 'views_handler_sort',
  507. ),
  508. 'filter' => array(
  509. 'handler' => 'views_handler_filter_numeric',
  510. ),
  511. );
  512. // Package tracking number field.
  513. $data['uc_packages']['tracking_number'] = array(
  514. 'title' => t('Tracking number'),
  515. 'help' => t('The number used by the carrier to locate the package while it is in transit.'),
  516. 'field' => array(
  517. 'handler' => 'views_handler_field',
  518. 'click sortable' => TRUE,
  519. ),
  520. 'sort' => array(
  521. 'handler' => 'views_handler_sort',
  522. ),
  523. 'filter' => array(
  524. 'handler' => 'views_handler_filter_string',
  525. ),
  526. 'argument' => array(
  527. 'handler' => 'views_handler_argument_string',
  528. ),
  529. );
  530. // Package length field.
  531. $data['uc_packages']['length'] = array(
  532. 'title' => t('Length'),
  533. 'help' => t('The physical length.'),
  534. 'field' => array(
  535. 'additional fields' => array(
  536. 'field' => 'length_units',
  537. ),
  538. 'handler' => 'uc_product_handler_field_length',
  539. 'click sortable' => TRUE,
  540. 'float' => TRUE,
  541. ),
  542. 'sort' => array(
  543. 'handler' => 'views_handler_sort',
  544. ),
  545. 'filter' => array(
  546. 'handler' => 'views_handler_filter_float',
  547. ),
  548. );
  549. // Package width field.
  550. $data['uc_packages']['width'] = array(
  551. 'title' => t('Width'),
  552. 'help' => t('The physical width.'),
  553. 'field' => array(
  554. 'additional fields' => array(
  555. 'field' => 'length_units',
  556. ),
  557. 'handler' => 'uc_product_handler_field_length',
  558. 'click sortable' => TRUE,
  559. 'float' => TRUE,
  560. ),
  561. 'sort' => array(
  562. 'handler' => 'views_handler_sort',
  563. ),
  564. 'filter' => array(
  565. 'handler' => 'views_handler_filter_float',
  566. ),
  567. );
  568. // Package height field.
  569. $data['uc_packages']['height'] = array(
  570. 'title' => t('Height'),
  571. 'help' => t('The physical height.'),
  572. 'field' => array(
  573. 'additional fields' => array(
  574. 'field' => 'length_units',
  575. ),
  576. 'handler' => 'uc_product_handler_field_length',
  577. 'click sortable' => TRUE,
  578. 'float' => TRUE,
  579. ),
  580. 'sort' => array(
  581. 'handler' => 'views_handler_sort',
  582. ),
  583. 'filter' => array(
  584. 'handler' => 'views_handler_filter_float',
  585. ),
  586. );
  587. // Package weight field.
  588. $data['uc_packages']['weight'] = array(
  589. 'title' => t('Weight'),
  590. 'help' => t('The physical weight of package.'),
  591. 'field' => array(
  592. 'additional fields' => array(
  593. 'package_id',
  594. ),
  595. 'handler' => 'uc_shipping_handler_field_package_weight',
  596. 'click sortable' => FALSE,
  597. 'float' => TRUE,
  598. ),
  599. );
  600. // Expose packaged products.
  601. $data['uc_packaged_products']['table']['group'] = t('Package: Product');
  602. // Expose packaged products to the ordered product as a relationship.
  603. // By using a relation and not expose fields directly we make sure that
  604. // when ordered products will be fieldable entities all their custom fields,
  605. // the one not stored in the schema, will get loaded.
  606. $data['uc_packaged_products']['uc_order_products'] = array(
  607. 'relationship' => array(
  608. 'title' => t('Ordered product'),
  609. 'help' => t('Relate packaged product to the ordered product.'),
  610. 'handler' => 'views_handler_relationship',
  611. 'base' => 'uc_order_products',
  612. 'base field' => 'order_product_id',
  613. 'relationship field' => 'order_product_id',
  614. 'label' => t('ordered product'),
  615. ),
  616. );
  617. // Packaged quantity field.
  618. $data['uc_packaged_products']['qty'] = array(
  619. 'title' => t('Quantity'),
  620. 'help' => t('The quantity packaged.'),
  621. 'field' => array(
  622. 'handler' => 'views_handler_field',
  623. 'click sortable' => TRUE,
  624. ),
  625. 'sort' => array(
  626. 'handler' => 'views_handler_sort',
  627. ),
  628. 'filter' => array(
  629. 'handler' => 'views_handler_filter_numeric',
  630. ),
  631. );
  632. return $data;
  633. }