You are here

function hook_commerce_discount_type_info in Commerce Discount 7

Defines the types of discounts available for creation on the site.

Each defined type is a bundle of the commerce_discount entity type, hence able to have its own fields attached.

The discount type array structure includes the following keys:

  • label: a translatable, human-readable discount type label.
  • event: the machine name of the rules event used to apply a discount of the defined type.
  • entity type: The type of entity to which the discount will be applied.

Return value

array An array of discount type arrays keyed by the machine name of the type.

1 function implements hook_commerce_discount_type_info()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

commerce_discount_commerce_discount_type_info in ./commerce_discount.module
Implements hook_commerce_discount_type_info().
1 invocation of hook_commerce_discount_type_info()
commerce_discount_types in ./commerce_discount.module
Return an array of all defined discount types.

File

./commerce_discount.api.php, line 23
Hooks provided by the Commerce Discount module.

Code

function hook_commerce_discount_type_info() {
  $types = array();
  $types['order_discount'] = array(
    'label' => t('Order Discount'),
    'event' => 'commerce_order_presave',
    'entity type' => 'commerce_order',
  );
  $types['product_discount'] = array(
    'label' => t('Product Discount'),
    'event' => 'commerce_product_calculate_sell_price',
    'entity type' => 'commerce_line_item',
  );
  return $types;
}