You are here

commerce_extra_panes.install in Commerce extra panes 7

Install file for Commerce extra panes.

File

commerce_extra_panes.install
View source
<?php

/**
 * @file
 * Install file for Commerce extra panes.
 */

/**
 * Implements hook_schema().
 */
function commerce_extra_panes_schema() {
  $schema = array();
  $schema['commerce_extra_panes'] = array(
    'description' => 'Extra panes configuration data.',
    'fields' => array(
      'extra_id' => array(
        'description' => 'Extra pane id.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'extra_type' => array(
        'description' => 'Entity type.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'status' => array(
        'description' => 'Boolean value indicating whether or not the pane is enabled.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 1,
      ),
    ),
    'primary key' => array(
      'extra_id',
      'extra_type',
    ),
  );
  return $schema;
}

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

  // Ensure that the body field is displayed in the checkout_pane view mode.
  $body = field_info_field('body');
  foreach ($body['entity_types'] as $entity_type) {
    $instances = field_read_instances(array(
      'entity_type' => $entity_type,
      'field_name' => 'body',
    ));
    foreach ($instances as $instance) {
      $instance['display']['checkout_pane'] = $instance['display']['default'];
      field_update_instance($instance);
    }
  }
}

Functions