You are here

commerce_registration.install in Commerce Registration 7.2

Same filename and directory in other branches
  1. 7.3 commerce_registration.install
  2. 7 commerce_registration.install

Commerce Registration install file.

Modify the registration schema to accomodate a commerce order ID number.

File

commerce_registration.install
View source
<?php

/**
 * @file
 * Commerce Registration install file.
 *
 * Modify the registration schema to accomodate a commerce order ID number.
 */

/**
 * Implements hook_schema().
 */
function commerce_registration_schema() {
  $schema = array();
  $schema['commerce_registration_node_settings'] = array(
    'description' => 'Registration settings for product display type nodes.',
    'fields' => array(
      'nid' => array(
        'type' => 'int',
        'description' => 'The node ID.',
        'not null' => TRUE,
      ),
      'settings' => array(
        'description' => 'Serialized array of settings for the node.',
        'type' => 'text',
        'size' => 'medium',
        'serialized' => TRUE,
      ),
    ),
    'primary key' => array(
      'nid',
    ),
  );
  return $schema;
}

/**
 * Implements hook_schema_alter().
 */
function commerce_registration_schema_alter(&$schema) {
  $schema['registration']['fields']['order_id'] = array(
    'description' => 'The order associated with this registration, if any.',
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
  );
}

/**
 * Implements hook_install().
 */
function commerce_registration_install() {

  // Add the new commerce order ID field to registrations.
  db_add_field("registration", "order_id", array(
    'description' => 'The order associated with this registration, if any.',
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
  ));
}

/**
 * Implements hook_uninstall().
 */
function commerce_registration_uninstall() {

  // Drop the order_id field from the registration table.
  db_drop_field("registration", "order_id");
}

/**
 * Adds the commerce_registration_node_settings table.
 */
function commerce_registration_update_7201() {
  if (!db_table_exists('commerce_registration_node_settings')) {
    db_create_table('commerce_registration_node_settings', drupal_get_schema_unprocessed('commerce_registration', 'commerce_registration_node_settings'));
  }
}

/**
 * Disable new default commerce_registration rules for existing implementations.
 */
function commerce_registration_update_7202() {
  variable_set('enable_commerce_registration_delete_rules', FALSE);
  return t("One new default Commerce Registration rule has been added. The rule deletes all registrations associated with a line item that is being deleted. The rule has been disabled by default to not interfere with existing order and registration workflows, but you may enable them through your rules admin UI.");
}

Functions

Namesort descending Description
commerce_registration_install Implements hook_install().
commerce_registration_schema Implements hook_schema().
commerce_registration_schema_alter Implements hook_schema_alter().
commerce_registration_uninstall Implements hook_uninstall().
commerce_registration_update_7201 Adds the commerce_registration_node_settings table.
commerce_registration_update_7202 Disable new default commerce_registration rules for existing implementations.