uc_product_kit.install in Ubercart 8.4
Same filename and directory in other branches
Install, update and uninstall functions for the uc_product_kit module.
File
uc_product_kit/uc_product_kit.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the uc_product_kit module.
*/
/**
* Implements hook_schema().
*/
function uc_product_kit_schema() {
$schema['uc_product_kits'] = [
'description' => 'Stores product kit information.',
'fields' => [
'vid' => [
'description' => 'The {node}.vid of the product kit.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
'nid' => [
'description' => 'The {node}.nid of the product kit.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
'product_id' => [
'description' => 'The {uc_products}.nid of a product contained in the kit.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
'mutable' => [
'description' => 'A flag indicating whether the contents of the kit can be changed by the customer. 1 => Mutable. 0 => Immutable.',
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
],
'qty' => [
'description' => 'The number of this product contained in the kit.',
'type' => 'int',
'size' => 'small',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
'discount' => [
'description' => 'The adjustment to the price of the product.',
'type' => 'float',
'not null' => TRUE,
'default' => 0.0,
],
'ordering' => [
'description' => 'The weight of this product in relation to other products in the kit.',
'type' => 'int',
'size' => 'small',
'not null' => TRUE,
'default' => 0,
],
'synchronized' => [
'description' => 'A flag indicating that changes to the price of this product will change the total price of the kit. 1 => Yes. 0 => No.',
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
],
],
'primary key' => [
'vid',
'product_id',
],
'foreign keys' => [
'node' => [
'table' => 'node',
'columns' => [
'nid' => 'nid',
'vid' => 'vid',
],
],
'uc_products' => [
'table' => 'uc_products',
'columns' => [
'product_id' => 'nid',
],
],
],
];
return $schema;
}
/**
* Implements hook_install().
*/
function uc_product_kit_install() {
// Do not allow the product kit content type to be deleted.
$locked = \Drupal::state()
->get('node.type.locked');
$locked['product_kit'] = 'product_kit';
\Drupal::state()
->set('node.type.locked', $locked);
// Add the product kit node type to the catalog if this module is installed
// some time after uc_catalog.
if (\Drupal::moduleHandler()
->moduleExists('uc_catalog')) {
uc_catalog_add_node_type('product_kit');
}
// Add a default image field to product kits.
uc_product_add_default_image_field('product_kit');
}
/**
* Implements hook_uninstall().
*/
function uc_product_kit_uninstall() {
// Allow the product kit content type to be deleted.
$locked = \Drupal::state()
->get('node.type.locked');
unset($locked['product_kit']);
\Drupal::state()
->set('node.type.locked', $locked);
}
Functions
Name | Description |
---|---|
uc_product_kit_install | Implements hook_install(). |
uc_product_kit_schema | Implements hook_schema(). |
uc_product_kit_uninstall | Implements hook_uninstall(). |