You are here

uc_ups.install in Ubercart 7.3

Install, update and uninstall functions for the uc_ups module.

File

shipping/uc_ups/uc_ups.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the uc_ups module.
 */

/**
 * Implements hook_schema().
 */
function uc_ups_schema() {
  $schema = array();
  $schema['uc_ups_products'] = array(
    'description' => 'Stores product information for UPS shipping quotes.',
    'fields' => array(
      'vid' => array(
        'description' => 'The {uc_products}.vid.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'nid' => array(
        'description' => 'The {uc_products}.nid.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'pkg_type' => array(
        'description' => 'The type of package in which the product will be shipped.',
        'type' => 'varchar',
        'length' => 2,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'vid',
    ),
    'foreign keys' => array(
      'uc_products' => array(
        'table' => 'uc_products',
        'columns' => array(
          'nid' => 'nid',
          'vid' => 'vid',
        ),
      ),
    ),
  );
  return $schema;
}

/**
 * Implements hook_uninstall().
 */
function uc_ups_uninstall() {
  variable_del('uc_ups_access_license');
  variable_del('uc_ups_shipper_number');
  variable_del('uc_ups_user_id');
  variable_del('uc_ups_password');
  variable_del('uc_ups_connection_address');
  variable_del('uc_ups_services');
  variable_del('uc_ups_pickup_type');
  variable_del('uc_ups_pkg_type');
  variable_del('uc_ups_classification');
  variable_del('uc_ups_negotiated_rates');
  variable_del('uc_ups_all_in_one');
  variable_del('uc_ups_unit_system');
  variable_del('uc_ups_insurance');
  variable_del('uc_ups_rate_markup');
  variable_del('uc_ups_rate_markup_type');
  variable_del('uc_ups_weight_markup');
  variable_del('uc_ups_weight_markup_type');
}

/**
 * Separates markup variables into rate_markup and weight_markup.
 */
function uc_ups_update_7300() {

  // Rename variables while preserving previous setting values
  variable_set('uc_ups_rate_markup', variable_get('uc_ups_markup', ''));
  variable_set('uc_ups_rate_markup_type', variable_get('uc_ups_markup_type', ''));

  // Remove old variables
  variable_del('uc_ups_markup');
  variable_del('uc_ups_markup_type');
}

/**
 * Updates UPS Production URL.
 */
function uc_ups_update_7301() {
  $current = variable_get('uc_ups_connection_address', '');

  // If currently using production URL, update variable to new value.
  if ($current == 'https://www.ups.com/ups.app/xml/') {
    variable_set('uc_ups_connection_address', 'https://onlinetools.ups.com/ups.app/xml/');
  }
}

Functions

Namesort descending Description
uc_ups_schema Implements hook_schema().
uc_ups_uninstall Implements hook_uninstall().
uc_ups_update_7300 Separates markup variables into rate_markup and weight_markup.
uc_ups_update_7301 Updates UPS Production URL.