function uc_discounts_schema in Ubercart Discounts (Alternative) 6.2
Same name and namespace in other branches
- 7.2 uc_discounts/uc_discounts.install \uc_discounts_schema()
@file Install hooks for uc_discounts.module.
5 calls to uc_discounts_schema()
- uc_discounts_update_6001 in uc_discounts/
uc_discounts.install - #984718, Add an activates_on date to discounts.
- uc_discounts_update_6002 in uc_discounts/
uc_discounts.install - #919730, Add the ability for a discount to qualify based on subtotal of all products
- uc_discounts_update_6003 in uc_discounts/
uc_discounts.install - #1100790, Add the ability for a discount max applications to be limited to number of required products in the cart
- uc_discounts_update_6005 in uc_discounts/
uc_discounts.install - #999778, Allow multiple products to be selected for discount qualification
- uc_discounts_update_6006 in uc_discounts/
uc_discounts.install - #1220388, Optionally allow free items to be automatically added to cart.
File
- uc_discounts/
uc_discounts.install, line 9 - Install hooks for uc_discounts.module.
Code
function uc_discounts_schema() {
$schema = array();
$schema["uc_discounts"] = array(
"fields" => array(
"discount_id" => array(
"type" => "serial",
"not null" => TRUE,
),
"name" => array(
"type" => "varchar",
"length" => 255,
"not null" => TRUE,
"default" => "",
),
"short_description" => array(
"type" => "varchar",
"length" => 100,
"not null" => TRUE,
"default" => "",
),
"description" => array(
"type" => "varchar",
"length" => 100,
"not null" => TRUE,
"default" => "",
),
"qualifying_type" => array(
"type" => "int",
"not null" => TRUE,
"default" => 0,
),
"qualifying_amount" => array(
"type" => "float",
"not null" => TRUE,
"default" => 0.0,
"description" => t("Minimum quantity or price required to qualify for this discount."),
),
"has_qualifying_amount_max" => array(
"type" => "int",
"size" => "tiny",
"not null" => TRUE,
"default" => 0,
"description" => t("Whether or not this discount has a max qualifying amount."),
),
"qualifying_amount_max" => array(
"type" => "float",
"not null" => TRUE,
"default" => 0.0,
"description" => t("Maximum quantity or price required to qualify for this discount."),
),
"discount_type" => array(
"type" => "int",
"not null" => TRUE,
"default" => 0,
),
"discount_amount" => array(
"type" => "float",
"not null" => TRUE,
"default" => 0.0,
"description" => t("Amount to discount (i.e. 1 free item, 25%, or \$2.00)"),
),
"requires_code" => array(
"type" => "int",
"size" => "tiny",
"not null" => TRUE,
"default" => 1,
"description" => t("Requires code to activate discount."),
),
"filter_type" => array(
"type" => "int",
"not null" => TRUE,
"default" => 1,
"description" => t("What type of object to filter on."),
),
"has_role_filter" => array(
"type" => "int",
"size" => "tiny",
"not null" => TRUE,
"default" => 0,
"description" => t("Whether or not this discount filters based on role."),
),
"use_only_discounted_products_to_qualify" => array(
"type" => "int",
"size" => "tiny",
"not null" => TRUE,
"default" => 0,
"description" => t("Calculate the order subtotal using only discounted products."),
),
"requires_single_product_to_qualify" => array(
"type" => "int",
"size" => "tiny",
"not null" => TRUE,
"default" => 1,
"description" => t("Requires qualifying amount to come from a single product."),
),
"required_product_type" => array(
"type" => "int",
'size' => 'tiny',
"not null" => TRUE,
"default" => 0,
),
"max_times_applied" => array(
"type" => "int",
"not null" => TRUE,
"default" => 1,
"description" => t("Number of times this discount can be applied to a single cart (0 for unlimited)."),
),
"limit_max_times_applied" => array(
"type" => "int",
"size" => "tiny",
"not null" => TRUE,
"default" => 0,
"description" => t("Whether or not to further limit the maximum times applied to the number of qualifying products."),
),
"can_be_combined_with_other_discounts" => array(
"type" => "int",
"size" => "tiny",
"not null" => TRUE,
"default" => 0,
"description" => t("Whether or not this discount will be applied if other discounts are."),
),
'add_to_cart' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => FALSE,
'default' => 0,
'description' => t('Indicates whether free items are added to cart by the module.'),
),
"max_uses" => array(
"type" => "int",
"not null" => TRUE,
"default" => 0,
"description" => t("Number of times this discount can be applied (0 for no limit)."),
),
"max_uses_per_user" => array(
"type" => "int",
"not null" => TRUE,
"default" => 1,
"description" => t("Number of times this discount can be applied to a particular user (0 for unlimited)."),
),
"max_uses_per_code" => array(
"type" => "int",
"not null" => TRUE,
"default" => 0,
"description" => t("Number of times this discount can be applied for a particular code (0 for unlimited)."),
),
"has_activation" => array(
"type" => "int",
"size" => "tiny",
"not null" => TRUE,
"default" => 0,
"description" => t("Whether or not discount has an activation date."),
),
"activates_on" => array(
"type" => "int",
"not null" => TRUE,
"default" => 0,
"description" => t("The activation date and time as a unix timestamp."),
),
"has_expiration" => array(
"type" => "int",
"size" => "tiny",
"not null" => TRUE,
"default" => 0,
"description" => t("Whether or not discount has an expiration."),
),
"expiration" => array(
"type" => "int",
"not null" => TRUE,
"default" => 0,
"description" => t("The exipration date and time as a unix timestamp."),
),
"is_active" => array(
"type" => "int",
"size" => "tiny",
"not null" => FALSE,
"default" => 0,
"description" => t("Convenience flag to state whether code is published on site or not."),
),
"weight" => array(
"type" => "int",
"size" => "tiny",
"not null" => TRUE,
"default" => 0,
),
"insert_timestamp" => array(
"type" => "int",
"not null" => TRUE,
"default" => 0,
"description" => t("The insert date and time as a unix timestamp."),
),
),
"primary key" => array(
"discount_id",
),
);
$schema["uc_discounts_codes"] = array(
"fields" => array(
"discount_code_id" => array(
"type" => "serial",
"not null" => TRUE,
),
"discount_id" => array(
"type" => "int",
"not null" => TRUE,
"default" => 0,
"description" => t("The {uc_discounts}.discount_id of the discount."),
),
"code" => array(
"type" => "varchar",
"length" => 100,
"not null" => TRUE,
"default" => "",
),
),
"primary key" => array(
"discount_code_id",
),
);
$schema["uc_discounts_products"] = array(
"fields" => array(
"discount_product_id" => array(
"type" => "serial",
"not null" => TRUE,
),
"discount_id" => array(
"type" => "int",
"not null" => TRUE,
"description" => t("The {uc_discounts}.discount_id of the discount."),
),
"product_id" => array(
"type" => "int",
"not null" => TRUE,
"description" => t("The {uc_products}.nid of the product being discounted."),
),
"grouping" => array(
"type" => "int",
"size" => "tiny",
"not null" => TRUE,
"default" => 1,
"description" => t("The grouping of this entry since required products be used in discount qualification or application."),
),
),
'indexes' => array(
'discount_id_grouping' => array(
'discount_id',
'grouping',
),
),
"primary key" => array(
"discount_product_id",
),
);
$schema["uc_discounts_terms"] = array(
"fields" => array(
"discount_term_id" => array(
"type" => "serial",
"not null" => TRUE,
),
"discount_id" => array(
"type" => "int",
"not null" => TRUE,
"description" => t("The {uc_discounts}.discount_id of the discount."),
),
"term_id" => array(
"type" => "int",
"not null" => TRUE,
"description" => t("The {term}.tid of the term being discounted."),
),
"grouping" => array(
"type" => "int",
"size" => "tiny",
"not null" => TRUE,
"default" => 1,
"description" => t("The grouping of this entry since required products be used in discount qualification or application."),
),
),
'indexes' => array(
'discount_id_grouping' => array(
'discount_id',
'grouping',
),
),
"primary key" => array(
"discount_term_id",
),
);
$schema["uc_discounts_skus"] = array(
"fields" => array(
"discount_sku_id" => array(
"type" => "serial",
"not null" => TRUE,
),
"discount_id" => array(
"type" => "int",
"not null" => TRUE,
"description" => t("The {uc_discounts}.discount_id of the discount."),
),
"sku" => array(
"type" => "varchar",
"length" => 255,
"not null" => TRUE,
"description" => t("The {uc_products}.model of the product being discounted."),
),
"grouping" => array(
"type" => "int",
"size" => "tiny",
"not null" => TRUE,
"default" => 1,
"description" => t("The grouping of this entry since required products be used in discount qualification or application."),
),
),
'indexes' => array(
'discount_id_grouping' => array(
'discount_id',
'grouping',
),
),
"primary key" => array(
"discount_sku_id",
),
);
$schema["uc_discounts_classes"] = array(
"fields" => array(
"discount_class_id" => array(
"type" => "serial",
"not null" => TRUE,
),
"discount_id" => array(
"type" => "int",
"not null" => TRUE,
"description" => t("The {uc_discounts}.discount_id of the discount."),
),
"class" => array(
"type" => "varchar",
"length" => 32,
"not null" => TRUE,
"description" => t("The {node_type}.type of the product being discounted."),
),
"grouping" => array(
"type" => "int",
"size" => "tiny",
"not null" => TRUE,
"default" => 1,
"description" => t("The grouping of this entry since required products be used in discount qualification or application."),
),
),
'indexes' => array(
'discount_id_grouping' => array(
'discount_id',
'grouping',
),
),
"primary key" => array(
"discount_class_id",
),
);
$schema["uc_discounts_authors"] = array(
"fields" => array(
"discount_author_id" => array(
"type" => "serial",
"not null" => TRUE,
),
"discount_id" => array(
"type" => "int",
"not null" => TRUE,
"description" => t("The {uc_discounts}.discount_id of the discount."),
),
"author_id" => array(
"type" => "int",
"not null" => TRUE,
"description" => t("The {users}.uid of the author being discounted."),
),
"grouping" => array(
"type" => "int",
"size" => "tiny",
"not null" => TRUE,
"default" => 1,
"description" => t("The grouping of this entry since required products be used in discount qualification or application."),
),
),
'indexes' => array(
'discount_id_grouping' => array(
'discount_id',
'grouping',
),
),
"primary key" => array(
"discount_author_id",
),
);
$schema["uc_discounts_roles"] = array(
"fields" => array(
"discount_role_id" => array(
"type" => "serial",
"not null" => TRUE,
),
"discount_id" => array(
"type" => "int",
"not null" => TRUE,
"description" => t("The {uc_discounts}.discount_id of the discount."),
),
"role_id" => array(
"type" => "int",
"not null" => TRUE,
"description" => t("The {role}.rid of the role required."),
),
),
"primary key" => array(
"discount_role_id",
),
);
$schema["uc_discounts_uses"] = array(
"fields" => array(
"discount_use_id" => array(
"type" => "serial",
"not null" => TRUE,
),
"discount_id" => array(
"type" => "int",
"not null" => TRUE,
"default" => 0,
"description" => t("The {uc_discounts}.discount_id of the discount."),
),
"user_id" => array(
"type" => "int",
"not null" => TRUE,
"default" => 0,
"description" => t("The {users}.uid of the user who used the discount or (0 if anonymous)."),
),
"order_id" => array(
"type" => "int",
"not null" => TRUE,
"default" => 0,
"description" => t("The {uc_orders}.order_id of the user's order."),
),
"code" => array(
"type" => "varchar",
"length" => 100,
"not null" => TRUE,
"default" => "",
"description" => t("Code used for discount."),
),
"times_applied" => array(
"type" => "int",
"not null" => TRUE,
"default" => 1,
"description" => t("Number of times this discount was applied."),
),
"amount" => array(
"type" => "float",
"not null" => TRUE,
"default" => 0,
"description" => t("Total amount of discount."),
),
"insert_timestamp" => array(
"type" => "int",
"not null" => TRUE,
"default" => 0,
"description" => t("The insert date and time as a unix timestamp."),
),
),
"primary key" => array(
"discount_use_id",
),
);
$schema["uc_discounts_order_codes"] = array(
"fields" => array(
"order_id" => array(
"type" => "int",
"not null" => TRUE,
"description" => t("The {uc_orders}.order_id of the user's order."),
),
"codes" => array(
"type" => "text",
"not null" => TRUE,
"description" => t("Newline delimited codes string for order."),
),
),
);
return $schema;
}