| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implementation of hook_install().
|
| 6 |
*/
|
| 7 |
function uc_order_schema() {
|
| 8 |
$schema = array();
|
| 9 |
|
| 10 |
$schema['uc_orders'] = array(
|
| 11 |
'description' => t('Main orders table.'),
|
| 12 |
'fields' => array(
|
| 13 |
'order_id' => array(
|
| 14 |
'description' => t('The order ID.'),
|
| 15 |
'type' => 'serial',
|
| 16 |
'unsigned' => TRUE,
|
| 17 |
'not null' => TRUE,
|
| 18 |
),
|
| 19 |
'uid' => array(
|
| 20 |
'description' => t('The ID of the user that placed the order.'),
|
| 21 |
'type' => 'int',
|
| 22 |
'unsigned' => TRUE,
|
| 23 |
'not null' => TRUE,
|
| 24 |
'default' => 0,
|
| 25 |
),
|
| 26 |
'order_status' => array(
|
| 27 |
'description' => t('The order status.'),
|
| 28 |
'type' => 'varchar',
|
| 29 |
'length' => 32,
|
| 30 |
'not null' => TRUE,
|
| 31 |
'default' => '',
|
| 32 |
),
|
| 33 |
'order_total' => array(
|
| 34 |
'description' => t('The total amount to be paid for the order.'),
|
| 35 |
'type' => 'numeric',
|
| 36 |
'precision' => 10,
|
| 37 |
'scale' => 2,
|
| 38 |
'not null' => TRUE,
|
| 39 |
'default' => 0.0,
|
| 40 |
),
|
| 41 |
'primary_email' => array(
|
| 42 |
'description' => t('The email address of the customer.'),
|
| 43 |
'type' => 'varchar',
|
| 44 |
'length' => 96,
|
| 45 |
'not null' => TRUE,
|
| 46 |
'default' => '',
|
| 47 |
),
|
| 48 |
'delivery_first_name' => array(
|
| 49 |
'description' => t('The first name of the person receiving shipment.'),
|
| 50 |
'type' => 'varchar',
|
| 51 |
'length' => 32,
|
| 52 |
'not null' => TRUE,
|
| 53 |
'default' => '',
|
| 54 |
),
|
| 55 |
'delivery_last_name' => array(
|
| 56 |
'description' => t('The last name of the person receiving shipment.'),
|
| 57 |
'type' => 'varchar',
|
| 58 |
'length' => 32,
|
| 59 |
'not null' => TRUE,
|
| 60 |
'default' => '',
|
| 61 |
),
|
| 62 |
'delivery_phone' => array(
|
| 63 |
'description' => t('The phone number at the delivery location.'),
|
| 64 |
'type' => 'varchar',
|
| 65 |
'length' => 32,
|
| 66 |
'not null' => TRUE,
|
| 67 |
'default' => '',
|
| 68 |
),
|
| 69 |
'delivery_company' => array(
|
| 70 |
'description' => t('The company at the delivery location.'),
|
| 71 |
'type' => 'varchar',
|
| 72 |
'length' => 64,
|
| 73 |
'not null' => TRUE,
|
| 74 |
'default' => '',
|
| 75 |
),
|
| 76 |
'delivery_street1' => array(
|
| 77 |
'description' => t('The street address of the delivery location.'),
|
| 78 |
'type' => 'varchar',
|
| 79 |
'length' => 64,
|
| 80 |
'not null' => TRUE,
|
| 81 |
'default' => '',
|
| 82 |
),
|
| 83 |
'delivery_street2' => array(
|
| 84 |
'description' => t('The second line of the street address.'),
|
| 85 |
'type' => 'varchar',
|
| 86 |
'length' => 64,
|
| 87 |
'not null' => TRUE,
|
| 88 |
'default' => '',
|
| 89 |
),
|
| 90 |
'delivery_city' => array(
|
| 91 |
'description' => t('The city of the delivery location.'),
|
| 92 |
'type' => 'varchar',
|
| 93 |
'length' => 32,
|
| 94 |
'not null' => TRUE,
|
| 95 |
'default' => '',
|
| 96 |
),
|
| 97 |
'delivery_zone' => array(
|
| 98 |
'description' => t('The state/zone/province id of the delivery location.'),
|
| 99 |
'type' => 'int',
|
| 100 |
'size' => 'medium',
|
| 101 |
'unsigned' => TRUE,
|
| 102 |
'not null' => TRUE,
|
| 103 |
'default' => 0,
|
| 104 |
),
|
| 105 |
'delivery_postal_code' => array(
|
| 106 |
'description' => t('The postal code of the delivery location.'),
|
| 107 |
'type' => 'varchar',
|
| 108 |
'length' => 10,
|
| 109 |
'not null' => TRUE,
|
| 110 |
'default' => '',
|
| 111 |
),
|
| 112 |
'delivery_country' => array(
|
| 113 |
'description' => t('The country ID of the delivery location.'),
|
| 114 |
'type' => 'int',
|
| 115 |
'size' => 'medium',
|
| 116 |
'unsigned' => TRUE,
|
| 117 |
'not null' => TRUE,
|
| 118 |
'default' => 0,
|
| 119 |
),
|
| 120 |
'billing_first_name' => array(
|
| 121 |
'description' => t('The first name of the person paying for the order.'),
|
| 122 |
'type' => 'varchar',
|
| 123 |
'length' => 32,
|
| 124 |
'not null' => TRUE,
|
| 125 |
'default' => '',
|
| 126 |
),
|
| 127 |
'billing_last_name' => array(
|
| 128 |
'description' => t('The last name of the person paying for the order.'),
|
| 129 |
'type' => 'varchar',
|
| 130 |
'length' => 32,
|
| 131 |
'not null' => TRUE,
|
| 132 |
'default' => '',
|
| 133 |
),
|
| 134 |
'billing_phone' => array(
|
| 135 |
'description' => t('The phone number for the billing address.'),
|
| 136 |
'type' => 'varchar',
|
| 137 |
'length' => 32,
|
| 138 |
'not null' => TRUE,
|
| 139 |
'default' => '',
|
| 140 |
),
|
| 141 |
'billing_company' => array(
|
| 142 |
'description' => t('The company of the billing address.'),
|
| 143 |
'type' => 'varchar',
|
| 144 |
'length' => 64,
|
| 145 |
'not null' => TRUE,
|
| 146 |
'default' => '',
|
| 147 |
),
|
| 148 |
'billing_street1' => array(
|
| 149 |
'description' => t('The street address where the bill will be sent.'),
|
| 150 |
'type' => 'varchar',
|
| 151 |
'length' => 64,
|
| 152 |
'not null' => TRUE,
|
| 153 |
'default' => '',
|
| 154 |
),
|
| 155 |
'billing_street2' => array(
|
| 156 |
'description' => t('The second line of the street address.'),
|
| 157 |
'type' => 'varchar',
|
| 158 |
'length' => 64,
|
| 159 |
'not null' => TRUE,
|
| 160 |
'default' => '',
|
| 161 |
),
|
| 162 |
'billing_city' => array(
|
| 163 |
'description' => t('The city where the bill will be sent.'),
|
| 164 |
'type' => 'varchar',
|
| 165 |
'length' => 32,
|
| 166 |
'not null' => TRUE,
|
| 167 |
'default' => '',
|
| 168 |
),
|
| 169 |
'billing_zone' => array(
|
| 170 |
'description' => t('The state/zone/province ID where the bill will be sent.'),
|
| 171 |
'type' => 'int',
|
| 172 |
'size' => 'medium',
|
| 173 |
'unsigned' => TRUE,
|
| 174 |
'not null' => TRUE,
|
| 175 |
'default' => 0,
|
| 176 |
),
|
| 177 |
'billing_postal_code' => array(
|
| 178 |
'description' => t('The postal code where the bill will be sent.'),
|
| 179 |
'type' => 'varchar',
|
| 180 |
'length' => 10,
|
| 181 |
'not null' => TRUE,
|
| 182 |
'default' => '',
|
| 183 |
),
|
| 184 |
'billing_country' => array(
|
| 185 |
'description' => t('The country ID where the bill will be sent.'),
|
| 186 |
'type' => 'int',
|
| 187 |
'size' => 'medium',
|
| 188 |
'unsigned' => TRUE,
|
| 189 |
'not null' => TRUE,
|
| 190 |
'default' => 0,
|
| 191 |
),
|
| 192 |
'payment_method' => array(
|
| 193 |
'description' => t('The method of payment.'),
|
| 194 |
'type' => 'varchar',
|
| 195 |
'length' => 32,
|
| 196 |
'not null' => TRUE,
|
| 197 |
'default' => '',
|
| 198 |
),
|
| 199 |
'data' => array(
|
| 200 |
'description' => t('Serialized array of extra data.'),
|
| 201 |
'type' => 'text',
|
| 202 |
),
|
| 203 |
'created' => array(
|
| 204 |
'description' => t('Timestamp of when the order was created.'),
|
| 205 |
'type' => 'int',
|
| 206 |
'not null' => TRUE,
|
| 207 |
'default' => 0,
|
| 208 |
),
|
| 209 |
'modified' => array(
|
| 210 |
'description' => t('Timestamp of when the order was last modified.'),
|
| 211 |
'type' => 'int',
|
| 212 |
'not null' => TRUE,
|
| 213 |
'default' => 0,
|
| 214 |
),
|
| 215 |
),
|
| 216 |
'indexes' => array(
|
| 217 |
'uc_orders_uid' => array('uid'),
|
| 218 |
'uc_orders_order_status' => array('order_status'),
|
| 219 |
),
|
| 220 |
'primary key' => array('order_id'),
|
| 221 |
);
|
| 222 |
|
| 223 |
$schema['uc_order_admin_comments'] = array(
|
| 224 |
'description' => t('Comments on orders that only administrators can see.'),
|
| 225 |
'fields' => array(
|
| 226 |
'comment_id' => array(
|
| 227 |
'description' => t('The comment ID.'),
|
| 228 |
'type' => 'serial',
|
| 229 |
'unsigned' => TRUE,
|
| 230 |
'not null' => TRUE,
|
| 231 |
),
|
| 232 |
'order_id' => array(
|
| 233 |
'description' => t('The order ID.'),
|
| 234 |
'type' => 'int',
|
| 235 |
'unsigned' => TRUE,
|
| 236 |
'not null' => TRUE,
|
| 237 |
'default' => 0,
|
| 238 |
),
|
| 239 |
'uid' => array(
|
| 240 |
'description' => t('The user ID who made the comment.'),
|
| 241 |
'type' => 'int',
|
| 242 |
'unsigned' => TRUE,
|
| 243 |
'not null' => TRUE,
|
| 244 |
'default' => 0,
|
| 245 |
),
|
| 246 |
'message' => array(
|
| 247 |
'description' => t('The comment body.'),
|
| 248 |
'type' => 'text',
|
| 249 |
),
|
| 250 |
'created' => array(
|
| 251 |
'description' => t('Timestamp of when the comment was created.'),
|
| 252 |
'type' => 'int',
|
| 253 |
'not null' => TRUE,
|
| 254 |
'default' => 0,
|
| 255 |
),
|
| 256 |
),
|
| 257 |
'indexes' => array(
|
| 258 |
'uc_order_admin_comments_order_id' => array('order_id'),
|
| 259 |
),
|
| 260 |
'primary key' => array('comment_id'),
|
| 261 |
);
|
| 262 |
|
| 263 |
$schema['uc_order_comments'] = array(
|
| 264 |
'description' => t('Comments on the order that the customer can see.'),
|
| 265 |
'fields' => array(
|
| 266 |
'comment_id' => array(
|
| 267 |
'description' => t('The comment ID.'),
|
| 268 |
'type' => 'serial',
|
| 269 |
'unsigned' => TRUE,
|
| 270 |
'not null' => TRUE,
|
| 271 |
),
|
| 272 |
'order_id' => array(
|
| 273 |
'description' => t('The order ID.'),
|
| 274 |
'type' => 'int',
|
| 275 |
'unsigned' => TRUE,
|
| 276 |
'not null' => TRUE,
|
| 277 |
'default' => 0,
|
| 278 |
),
|
| 279 |
'uid' => array(
|
| 280 |
'description' => t('The user ID who made the comment.'),
|
| 281 |
'type' => 'int',
|
| 282 |
'unsigned' => TRUE,
|
| 283 |
'not null' => TRUE,
|
| 284 |
'default' => 0,
|
| 285 |
),
|
| 286 |
'order_status' => array(
|
| 287 |
'description' => t('The status the order had when the comment was made.'),
|
| 288 |
'type' => 'varchar',
|
| 289 |
'length' => 32,
|
| 290 |
'not null' => TRUE,
|
| 291 |
'default' => '',
|
| 292 |
),
|
| 293 |
'notified' => array(
|
| 294 |
'description' => t('Boolean flag; if set, the comment was emailed to the customer.'),
|
| 295 |
'type' => 'int',
|
| 296 |
'size' => 'tiny',
|
| 297 |
'not null' => TRUE,
|
| 298 |
'default' => 0,
|
| 299 |
),
|
| 300 |
'message' => array(
|
| 301 |
'description' => t('Timestamp of when the comment was created.'),
|
| 302 |
'type' => 'text',
|
| 303 |
),
|
| 304 |
'created' => array(
|
| 305 |
'type' => 'int',
|
| 306 |
'not null' => TRUE,
|
| 307 |
'default' => 0,
|
| 308 |
),
|
| 309 |
),
|
| 310 |
'indexes' => array(
|
| 311 |
'uc_order_comments_order_id' => array('order_id'),
|
| 312 |
),
|
| 313 |
'primary key' => array('comment_id'),
|
| 314 |
);
|
| 315 |
|
| 316 |
$schema['uc_order_line_items'] = array(
|
| 317 |
'description' => t('Order line items other than products.'),
|
| 318 |
'fields' => array(
|
| 319 |
'line_item_id' => array(
|
| 320 |
'description' => t('The line item ID.'),
|
| 321 |
'type' => 'serial',
|
| 322 |
'unsigned' => TRUE,
|
| 323 |
'not null' => TRUE,
|
| 324 |
),
|
| 325 |
'order_id' => array(
|
| 326 |
'description' => t('The order ID.'),
|
| 327 |
'type' => 'int',
|
| 328 |
'unsigned' => TRUE,
|
| 329 |
'not null' => TRUE,
|
| 330 |
'default' => 0,
|
| 331 |
),
|
| 332 |
'type' => array(
|
| 333 |
'description' => t('The line item type.'),
|
| 334 |
'type' => 'varchar',
|
| 335 |
'length' => 32,
|
| 336 |
'not null' => TRUE,
|
| 337 |
'default' => '',
|
| 338 |
),
|
| 339 |
'title' => array(
|
| 340 |
'description' => t('The label of the line item.'),
|
| 341 |
'type' => 'varchar',
|
| 342 |
'length' => 128,
|
| 343 |
'not null' => TRUE,
|
| 344 |
'default' => '',
|
| 345 |
),
|
| 346 |
'amount' => array(
|
| 347 |
'description' => t("The amount of the line item in the store's currency."),
|
| 348 |
'type' => 'numeric',
|
| 349 |
'precision' => 10,
|
| 350 |
'scale' => 2,
|
| 351 |
'not null' => TRUE,
|
| 352 |
'default' => 0.0,
|
| 353 |
),
|
| 354 |
'weight' => array(
|
| 355 |
'description' => t('The sort criteria of line items.'),
|
| 356 |
'type' => 'int',
|
| 357 |
'size' => 'small',
|
| 358 |
'not null' => TRUE,
|
| 359 |
'default' => 0,
|
| 360 |
),
|
| 361 |
),
|
| 362 |
'indexes' => array(
|
| 363 |
'uc_order_line_items_order_id' => array('order_id'),
|
| 364 |
),
|
| 365 |
'primary key' => array('line_item_id'),
|
| 366 |
);
|
| 367 |
|
| 368 |
$schema['uc_order_log'] = array(
|
| 369 |
'description' => t('Record of changes made to an order.'),
|
| 370 |
'fields' => array(
|
| 371 |
'order_log_id' => array(
|
| 372 |
'description' => t('The log entry ID.'),
|
| 373 |
'type' => 'serial',
|
| 374 |
'unsigned' => TRUE,
|
| 375 |
'not null' => TRUE,
|
| 376 |
),
|
| 377 |
'order_id' => array(
|
| 378 |
'description' => t('The order ID.'),
|
| 379 |
'type' => 'int',
|
| 380 |
'unsigned' => TRUE,
|
| 381 |
'not null' => TRUE,
|
| 382 |
'default' => 0,
|
| 383 |
),
|
| 384 |
'uid' => array(
|
| 385 |
'description' => t('The user ID who made the changes.'),
|
| 386 |
'type' => 'int',
|
| 387 |
'unsigned' => TRUE,
|
| 388 |
'not null' => TRUE,
|
| 389 |
'default' => 0,
|
| 390 |
),
|
| 391 |
'changes' => array(
|
| 392 |
'description' => t('Description of what was changed.'),
|
| 393 |
'type' => 'text',
|
| 394 |
),
|
| 395 |
'created' => array(
|
| 396 |
'description' => t('Timestamp of when the change was made.'),
|
| 397 |
'type' => 'int',
|
| 398 |
'not null' => TRUE,
|
| 399 |
'default' => 0,
|
| 400 |
),
|
| 401 |
),
|
| 402 |
'indexes' => array(
|
| 403 |
'uc_order_log_order_id' => array('order_id'),
|
| 404 |
),
|
| 405 |
'primary key' => array('order_log_id'),
|
| 406 |
);
|
| 407 |
|
| 408 |
$schema['uc_order_products'] = array(
|
| 409 |
'description' => t('The products that have been ordered.'),
|
| 410 |
'fields' => array(
|
| 411 |
'order_product_id' => array(
|
| 412 |
'description' => t('The ordered product ID.'),
|
| 413 |
'type' => 'serial',
|
| 414 |
'unsigned' => TRUE,
|
| 415 |
'not null' => TRUE,
|
| 416 |
),
|
| 417 |
'order_id' => array(
|
| 418 |
'description' => t('The order ID.'),
|
| 419 |
'type' => 'int',
|
| 420 |
'unsigned' => TRUE,
|
| 421 |
'not null' => TRUE,
|
| 422 |
'default' => 0,
|
| 423 |
),
|
| 424 |
'nid' => array(
|
| 425 |
'description' => t('The product node ID.'),
|
| 426 |
'type' => 'int',
|
| 427 |
'unsigned' => TRUE,
|
| 428 |
'not null' => TRUE,
|
| 429 |
'default' => 0,
|
| 430 |
),
|
| 431 |
'title' => array(
|
| 432 |
'description' => t('The product title.'),
|
| 433 |
'type' => 'varchar',
|
| 434 |
'length' => 128,
|
| 435 |
'not null' => TRUE,
|
| 436 |
'default' => '',
|
| 437 |
),
|
| 438 |
'manufacturer' => array(
|
| 439 |
'description' => t('The product manufacturer. (Deprecated)'),
|
| 440 |
'type' => 'varchar',
|
| 441 |
'length' => 32,
|
| 442 |
'not null' => TRUE,
|
| 443 |
'default' => '',
|
| 444 |
),
|
| 445 |
'model' => array(
|
| 446 |
'description' => t('The product model/SKU.'),
|
| 447 |
'type' => 'varchar',
|
| 448 |
'length' => 255,
|
| 449 |
'not null' => TRUE,
|
| 450 |
'default' => '',
|
| 451 |
),
|
| 452 |
'qty' => array(
|
| 453 |
'description' => t('The number of the same product ordered.'),
|
| 454 |
'type' => 'int',
|
| 455 |
'size' => 'small',
|
| 456 |
'unsigned' => TRUE,
|
| 457 |
'not null' => TRUE,
|
| 458 |
'default' => 0,
|
| 459 |
),
|
| 460 |
'cost' => array(
|
| 461 |
'description' => t('The cost to the store for the product.'),
|
| 462 |
'type' => 'numeric',
|
| 463 |
'precision' => 10,
|
| 464 |
'scale' => 2,
|
| 465 |
'unsigned' => TRUE,
|
| 466 |
'not null' => TRUE,
|
| 467 |
'default' => 0.0,
|
| 468 |
),
|
| 469 |
'price' => array(
|
| 470 |
'description' => t('The price paid for the ordered product.'),
|
| 471 |
'type' => 'numeric',
|
| 472 |
'precision' => 10,
|
| 473 |
'scale' => 2,
|
| 474 |
'unsigned' => TRUE,
|
| 475 |
'not null' => TRUE,
|
| 476 |
'default' => 0.0,
|
| 477 |
),
|
| 478 |
'weight' => array(
|
| 479 |
'description' => t('The physical weight.'),
|
| 480 |
'type' => 'float',
|
| 481 |
'unsigned' => TRUE,
|
| 482 |
'not null' => TRUE,
|
| 483 |
'default' => 0.0,
|
| 484 |
),
|
| 485 |
'data' => array(
|
| 486 |
'description' => t('Serialized array of extra data.'),
|
| 487 |
'type' => 'text',
|
| 488 |
),
|
| 489 |
),
|
| 490 |
'indexes' => array(
|
| 491 |
'uc_order_products_order_id' => array('order_id'),
|
| 492 |
),
|
| 493 |
'primary key' => array('order_product_id'),
|
| 494 |
);
|
| 495 |
|
| 496 |
$schema['uc_order_statuses'] = array(
|
| 497 |
'description' => t('Statuses the order can be in during its lifecycle.'),
|
| 498 |
'fields' => array(
|
| 499 |
'order_status_id' => array(
|
| 500 |
'description' => t('The order status ID.'),
|
| 501 |
'type' => 'varchar',
|
| 502 |
'length' => 32,
|
| 503 |
'not null' => TRUE,
|
| 504 |
'default' => '',
|
| 505 |
),
|
| 506 |
'title' => array(
|
| 507 |
'description' => t('The status title.'),
|
| 508 |
'type' => 'varchar',
|
| 509 |
'length' => 48,
|
| 510 |
'not null' => TRUE,
|
| 511 |
'default' => '',
|
| 512 |
),
|
| 513 |
'state' => array(
|
| 514 |
'description' => t('The base order state the status is associated with.'),
|
| 515 |
'type' => 'varchar',
|
| 516 |
'length' => 32,
|
| 517 |
'not null' => TRUE,
|
| 518 |
'default' => '',
|
| 519 |
),
|
| 520 |
'weight' => array(
|
| 521 |
'description' => t('The sort criteria for statuses.'),
|
| 522 |
'type' => 'int',
|
| 523 |
'size' => 'small',
|
| 524 |
'not null' => TRUE,
|
| 525 |
'default' => 0,
|
| 526 |
),
|
| 527 |
'locked' => array(
|
| 528 |
'description' => t('Boolean flag; if set, users can not delete the status.'),
|
| 529 |
'type' => 'int',
|
| 530 |
'size' => 'tiny',
|
| 531 |
'unsigned' => TRUE,
|
| 532 |
'not null' => TRUE,
|
| 533 |
'default' => 0,
|
| 534 |
),
|
| 535 |
),
|
| 536 |
'primary key' => array('order_status_id'),
|
| 537 |
);
|
| 538 |
|
| 539 |
return $schema;
|
| 540 |
}
|
| 541 |
|
| 542 |
function uc_order_install() {
|
| 543 |
drupal_install_schema('uc_order');
|
| 544 |
|
| 545 |
$t = get_t();
|
| 546 |
db_query("INSERT INTO {uc_order_statuses} (order_status_id, title, state, weight, locked) VALUES ('canceled', '". $t('Canceled') ."', 'canceled', -20, 1);");
|
| 547 |
db_query("INSERT INTO {uc_order_statuses} (order_status_id, title, state, weight, locked) VALUES ('in_checkout', '". $t('In checkout') ."', 'in_checkout', -10, 1);");
|
| 548 |
db_query("INSERT INTO {uc_order_statuses} (order_status_id, title, state, weight, locked) VALUES ('pending', '". $t('Pending') ."', 'post_checkout', 0, 1);");
|
| 549 |
db_query("INSERT INTO {uc_order_statuses} (order_status_id, title, state, weight, locked) VALUES ('processing', '". $t('Processing') ."', 'post_checkout', 5, 1);");
|
| 550 |
db_query("INSERT INTO {uc_order_statuses} (order_status_id, title, state, weight, locked) VALUES ('completed', '". $t('Completed') ."', 'completed', 20, 1);");
|
| 551 |
}
|
| 552 |
|
| 553 |
function uc_order_uninstall() {
|
| 554 |
drupal_uninstall_schema('uc_order');
|
| 555 |
|
| 556 |
db_query("DELETE FROM {variable} WHERE name LIKE 'uc_order_pane_%'");
|
| 557 |
db_query("DELETE FROM {variable} WHERE name LIKE 'uc_state_%'");
|
| 558 |
variable_del('uc_order_number_displayed');
|
| 559 |
variable_del('uc_order_logging');
|
| 560 |
variable_del('uc_order_capitalize_addresses');
|
| 561 |
variable_del('uc_ubrowser_product_select');
|
| 562 |
variable_del('uc_cust_view_order_invoices');
|
| 563 |
variable_del('uc_cust_order_invoice_template');
|
| 564 |
}
|
| 565 |
|
| 566 |
function uc_order_update_1() {
|
| 567 |
switch ($GLOBALS['db_type']) {
|
| 568 |
case 'mysql':
|
| 569 |
case 'mysqli':
|
| 570 |
$ret[] = update_sql("ALTER TABLE {uc_orders} CHANGE delivery_zip delivery_postal_code VARCHAR(10) CHARACTER SET utf8 NOT NULL");
|
| 571 |
$ret[] = update_sql("ALTER TABLE {uc_orders} CHANGE billing_zip billing_postal_code VARCHAR(10) CHARACTER SET utf8 NOT NULL");
|
| 572 |
break;
|
| 573 |
case 'pgsql':
|
| 574 |
db_change_column($ret, 'uc_orders', 'delivery_zip', 'delivery_postal_code', 'varchar(10) CHARACTER SET utf8', array('not null' => true, 'default' => ''));
|
| 575 |
db_change_column($ret, 'uc_orders', 'billing_zip', 'billing_postal_code', 'varchar(10) CHARACTER SET utf8', array('not null' => true, 'default' => ''));
|
| 576 |
break;
|
| 577 |
}
|
| 578 |
$result = db_query("SELECT order_id FROM {uc_orders} ORDER BY order_id DESC LIMIT 1");
|
| 579 |
if ($data = db_fetch_object($result)) {
|
| 580 |
$result = db_query("INSERT INTO {sequences} (name, id) VALUES ('{uc_orders}_order_id', %d)", $data->order_id);
|
| 581 |
$ret[] = array('success' => $result !== false, 'query' => "INSERT INTO {sequences} (name, id) VALUES ('{uc_orders}_order_id'. ". $data->order_id .")");
|
| 582 |
}
|
| 583 |
return $ret;
|
| 584 |
}
|
| 585 |
|
| 586 |
function uc_order_update_2() {
|
| 587 |
switch ($GLOBALS['db_type']) {
|
| 588 |
case 'mysql':
|
| 589 |
case 'mysqli':
|
| 590 |
$ret[] = update_sql("ALTER TABLE {uc_order_products} CHANGE weight weight FLOAT NOT NULL DEFAULT 0.0");
|
| 591 |
break;
|
| 592 |
case 'pgsql':
|
| 593 |
db_change_column($ret, 'uc_order_products', 'weight', 'weight', 'float', array('not null' => true, 'default' => 0.0));
|
| 594 |
break;
|
| 595 |
}
|
| 596 |
return $ret;
|
| 597 |
}
|
| 598 |
|
| 599 |
function uc_order_update_3() {
|
| 600 |
$ret = array();
|
| 601 |
// Update orders and comments to hold string values for order statuses.
|
| 602 |
switch ($GLOBALS['db_type']) {
|
| 603 |
case 'mysql':
|
| 604 |
case 'mysqli':
|
| 605 |
$ret[] = update_sql("ALTER TABLE {uc_orders} CHANGE order_status order_status VARCHAR(32) NOT NULL");
|
| 606 |
$ret[] = update_sql("ALTER TABLE {uc_order_comments} CHANGE order_status order_status VARCHAR(32) NOT NULL");
|
| 607 |
break;
|
| 608 |
case 'pgsql':
|
| 609 |
db_change_column($ret, 'uc_orders', 'order_status', 'order_status', 'varchar(32)', array('not null' => true, 'default' => ''));
|
| 610 |
db_change_column($ret, 'uc_order_comments', 'order_status', 'order_status', 'varchar(32)', array('not null' => true, 'default' => ''));
|
| 611 |
break;
|
| 612 |
}
|
| 613 |
$ret[] = update_sql("UPDATE {uc_orders} SET order_status = 'in_checkout' WHERE order_status = '0'");
|
| 614 |
$ret[] = update_sql("UPDATE {uc_orders} SET order_status = 'pending' WHERE order_status = '1'");
|
| 615 |
$ret[] = update_sql("UPDATE {uc_orders} SET order_status = 'processing' WHERE order_status = '2' OR order_status = '3'");
|
| 616 |
$ret[] = update_sql("UPDATE {uc_orders} SET order_status = 'completed' WHERE order_status = '4'");
|
| 617 |
|
| 618 |
$ret[] = update_sql("UPDATE {uc_order_comments} SET order_status = 'in_checkout' WHERE order_status = '0'");
|
| 619 |
$ret[] = update_sql("UPDATE {uc_order_comments} SET order_status = 'pending' WHERE order_status = '1'");
|
| 620 |
$ret[] = update_sql("UPDATE {uc_order_comments} SET order_status = 'processing' WHERE order_status = '2' OR order_status = '3'");
|
| 621 |
$ret[] = update_sql("UPDATE {uc_order_comments} SET order_status = 'completed' WHERE order_status = '4'");
|
| 622 |
|
| 623 |
// Clean out the old order status table and redefine its structure.
|
| 624 |
if ($_SESSION['statuses'] !== TRUE) {
|
| 625 |
switch ($GLOBALS['db_type']) {
|
| 626 |
case 'mysql':
|
| 627 |
case 'mysqli':
|
| 628 |
$ret[] = update_sql("ALTER TABLE {uc_order_statuses} CHANGE order_status_id order_status_id VARCHAR(32) CHARACTER SET utf8 NOT NULL default ''");
|
| 629 |
$ret[] = update_sql("ALTER TABLE {uc_order_statuses} CHANGE title title VARCHAR(48) CHARACTER SET utf8 NOT NULL default ''");
|
| 630 |
$ret[] = update_sql("ALTER TABLE {uc_order_statuses} CHANGE notify state VARCHAR(32) CHARACTER SET utf8 NOT NULL default ''");
|
| 631 |
$ret[] = update_sql("ALTER TABLE {uc_order_statuses} ADD weight MEDIUMINT(9) NOT NULL");
|
| 632 |
$ret[] = update_sql("ALTER TABLE {uc_order_statuses} ADD locked TINYINT NOT NULL DEFAULT '0'");
|
| 633 |
break;
|
| 634 |
case 'pgsql':
|
| 635 |
db_change_column($ret, 'uc_order_statuses', 'order_status_id', 'order_status_id', 'varchar(32) CHARACTER SET utf8', array('not null' => true, 'default' => ''));
|
| 636 |
db_change_column($ret, 'uc_order_statuses', 'title', 'title', 'varchar(48) CHARACTER SET utf8', array('not null' => true, 'default' => ''));
|
| 637 |
db_change_column($ret, 'uc_order_statuses', 'notify', 'state', 'varchar(32) CHARACTER SET utf8', array('not null' => true, 'default' => ''));
|
| 638 |
db_add_column($ret, 'uc_order_statuses', 'weight', 'integer', array('not null' => true, 'default' => 0));
|
| 639 |
db_add_column($ret, 'uc_order_statuses', 'locked', 'smallint', array('not null' => true, 'default' => 0));
|
| 640 |
break;
|
| 641 |
}
|
| 642 |
$ret[] = update_sql("DELETE FROM {uc_order_statuses} WHERE order_status_id LIKE '_'");
|
| 643 |
$_SESSION['statuses'] = TRUE;
|
| 644 |
}
|
| 645 |
|
| 646 |
// Fill the table with the new default order statuses.
|
| 647 |
$t = get_t();
|
| 648 |
$ret[] = update_sql("INSERT INTO {uc_order_statuses} (order_status_id, title, state, weight, locked) VALUES "
|
| 649 |
."('canceled', '". $t('Canceled') ."', 'canceled', -20, 1), "
|
| 650 |
."('in_checkout', '". $t('In checkout') ."', 'in_checkout', -10, 1), "
|
| 651 |
."('pending', '". $t('Pending') ."', 'post_checkout', 0, 1), "
|
| 652 |
."('processing', '". $t('Processing') ."', 'post_checkout', 5, 1), "
|
| 653 |
."('completed', '". $t('Completed') ."', 'completed', 20, 1);");
|
| 654 |
|
| 655 |
return $ret;
|
| 656 |
}
|
| 657 |
|
| 658 |
function uc_order_update_4() {
|
| 659 |
$ret = array();
|
| 660 |
// Because I forgot to change the CREATE statement...
|
| 661 |
switch ($GLOBALS['db_type']) {
|
| 662 |
case 'mysql':
|
| 663 |
case 'mysqli':
|
| 664 |
$ret[] = update_sql("ALTER TABLE {uc_order_comments} CHANGE order_status order_status VARCHAR(32) NOT NULL");
|
| 665 |
break;
|
| 666 |
case 'pgsql':
|
| 667 |
db_change_column($ret, 'uc_order_comments', 'order_status', 'order_status', 'varchar(32)', array('not null' => true, 'default' => ''));
|
| 668 |
break;
|
| 669 |
}
|
| 670 |
|
| 671 |
return $ret;
|
| 672 |
}
|
| 673 |
|
| 674 |
function uc_order_update_5() {
|
| 675 |
switch ($GLOBALS['db_type']) {
|
| 676 |
case 'mysql':
|
| 677 |
case 'mysqli':
|
| 678 |
$ret[] = update_sql("ALTER TABLE {uc_orders} ADD data text");
|
| 679 |
break;
|
| 680 |
case 'pgsql':
|
| 681 |
db_add_column($ret, 'uc_orders', 'data', 'text', array());
|
| 682 |
break;
|
| 683 |
}
|
| 684 |
|
| 685 |
return $ret;
|
| 686 |
}
|
| 687 |
|
| 688 |
function uc_order_update_6() {
|
| 689 |
$ret = array();
|
| 690 |
$max_opid = db_result(db_query("SELECT MAX(order_product_id) AS max_opid FROM {uc_order_products}"));
|
| 691 |
if ($max_opid) {
|
| 692 |
$ret[] = update_sql("INSERT INTO {sequences} (name, id) VALUES ('{uc_order_products}_order_product_id', $max_opid)");
|
| 693 |
}
|
| 694 |
return $ret;
|
| 695 |
}
|
| 696 |
|
| 697 |
function uc_order_update_7() {
|
| 698 |
$ret = array();
|
| 699 |
switch ($GLOBALS['db_type']) {
|
| 700 |
case 'mysql':
|
| 701 |
case 'mysqli':
|
| 702 |
$ret[] = update_sql("ALTER TABLE {uc_order_products} CHANGE model model VARCHAR(255) CHARACTER SET utf8 NOT NULL");
|
| 703 |
break;
|
| 704 |
case 'pgsql':
|
| 705 |
db_change_column($ret, 'uc_order_products', 'model', 'model', 'varchar(255)', array('not null' => TRUE, 'default' => ''));
|
| 706 |
break;
|
| 707 |
}
|
| 708 |
|
| 709 |
return $ret;
|
| 710 |
}
|
| 711 |
|