You are here

function hook_commerce_discount_offer_type_info in Commerce Discount 7

Defines the types of discount offers available for creation on the site.

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

The discount offer type array structure includes the following keys:

  • label: a translatable, human-readable discount offer type label.
  • action: the Rules function callback used to apply a discount offer of the defined type to an entity.
  • event (optional): the machine name of the rules event used to apply a discount of the defined type. This one will override the default discount type event. If you need to alter event parameters, you have to implement the hook_commerce_discount_rule_build() in your module.
  • entity types: The entity types that this offer handles. Only offers that support the "entity type" of the selected discount type are shown in the UI.

Return value

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

1 function implements hook_commerce_discount_offer_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_offer_type_info in ./commerce_discount.module
Implements hook_commerce_discount_offer_type_info().
1 invocation of hook_commerce_discount_offer_type_info()
commerce_discount_offer_types in ./commerce_discount.module
Return an array of all defined discount offer types.

File

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

Code

function hook_commerce_discount_offer_type_info() {
  $types = array();
  $types['random_amount'] = array(
    'label' => t('Random $ off'),
    'action' => 'foo_random_amount',
    'event' => 'foo_random_rules_event',
    'entity types' => array(
      'commerce_order',
      'commerce_line_item',
    ),
  );
  return $types;
}