uc_cart.install 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the uc_cart module.
  5. */
  6. /**
  7. * Implements hook_schema().
  8. */
  9. function uc_cart_schema() {
  10. $schema = array();
  11. $schema['uc_cart_products'] = array(
  12. 'description' => 'Stores products placed in shopping carts.',
  13. 'fields' => array(
  14. 'cart_item_id' => array(
  15. 'description' => 'Unique identifier for cart item.',
  16. 'type' => 'serial',
  17. 'unsigned' => TRUE,
  18. 'not null' => TRUE,
  19. ),
  20. 'cart_id' => array(
  21. 'description' => 'A user-specific cart ID. For authenticated users, their {users}.uid. For anonymous users, a token.',
  22. 'type' => 'varchar',
  23. 'length' => 255,
  24. 'not null' => TRUE,
  25. 'default' => '0',
  26. ),
  27. 'nid' => array(
  28. 'description' => 'The {node}.nid of the product.',
  29. 'type' => 'int',
  30. 'unsigned' => TRUE,
  31. 'not null' => TRUE,
  32. 'default' => 0,
  33. ),
  34. 'qty' => array(
  35. 'description' => 'The number of this product in the cart.',
  36. 'type' => 'int',
  37. 'unsigned' => TRUE,
  38. 'not null' => TRUE,
  39. 'default' => 0,
  40. ),
  41. 'changed' => array(
  42. 'description' => 'The Unix timestamp indicating the time the product in the cart was changed.',
  43. 'type' => 'int',
  44. 'not null' => TRUE,
  45. 'default' => 0,
  46. ),
  47. 'data' => array(
  48. 'description' => 'A serialized array of extra cart data for the product.',
  49. 'type' => 'text',
  50. 'serialize' => TRUE,
  51. ),
  52. ),
  53. 'indexes' => array(
  54. 'cart_id' => array('cart_id'),
  55. ),
  56. 'primary key' => array('cart_item_id'),
  57. 'foreign keys' => array(
  58. 'node' => array(
  59. 'table' => 'node',
  60. 'columns' => array('nid' => 'nid'),
  61. ),
  62. ),
  63. );
  64. return $schema;
  65. }
  66. /**
  67. * Implements hook_uninstall().
  68. */
  69. function uc_cart_uninstall() {
  70. db_delete('variable')
  71. ->condition('name', 'uc_cart_%', 'LIKE')
  72. ->condition('name', 'uc_pane_%', 'LIKE')
  73. ->condition('name', 'uc_cap_%', 'LIKE')
  74. ->condition('name', 'uc_checkout_%', 'LIKE')
  75. ->condition('name', 'uc_msg_%', 'LIKE')
  76. ->condition('name', 'uc_new_customer_%', 'LIKE')
  77. ->execute();
  78. variable_del('uc_minimum_subtotal');
  79. variable_del('uc_add_item_redirect');
  80. variable_del('uc_continue_shopping_url');
  81. variable_del('uc_continue_shopping_type');
  82. variable_del('uc_use_next_buttons');
  83. variable_del('uc_collapse_current_pane');
  84. variable_del('uc_checkout_email_customer');
  85. variable_del('uc_checkout_email_admin');
  86. }
  87. /**
  88. * Implements hook_update_last_removed().
  89. */
  90. function uc_cart_update_last_removed() {
  91. // 7.x-3.0-beta2 and earlier were installed with schema version 0,
  92. // which causes update.php to fail.
  93. return drupal_get_installed_schema_version('uc_cart') == 0 ? 0 : 6201;
  94. }
  95. /**
  96. * Unify cart block title setting.
  97. */
  98. function uc_cart_update_6202() {
  99. variable_del('uc_cart_block_title');
  100. }
  101. /**
  102. * Remove unused text format variables.
  103. */
  104. function uc_cart_update_7000() {
  105. variable_del('uc_checkout_instructions_format');
  106. variable_del('uc_checkout_review_instructions_format');
  107. variable_del('uc_msg_order_submit_format');
  108. variable_del('uc_msg_order_logged_in_format');
  109. variable_del('uc_msg_order_existing_user_format');
  110. variable_del('uc_msg_order_new_user_format');
  111. variable_del('uc_msg_continue_shopping_format');
  112. }
  113. /**
  114. * Increase maximum cart item quantity.
  115. */
  116. function uc_cart_update_7001() {
  117. db_change_field('uc_cart_products', 'qty', 'qty', array(
  118. 'description' => 'The number of this product in the cart.',
  119. 'type' => 'int',
  120. 'unsigned' => TRUE,
  121. 'not null' => TRUE,
  122. 'default' => 0,
  123. ));
  124. }
  125. /**
  126. * Remove unused variable.
  127. */
  128. function uc_cart_update_7300() {
  129. variable_del('uc_continue_shopping_text');
  130. }