You are here

function commerce_coupon_type_save in Commerce Coupon 7

Saves a coupon type to the database.

Parameters

$type: The CommerceCouponType object to store.

$reset: Optional Should add the configuration to coupon type. (default: TRUE)

Return value

CommerceCouponType The stored CommerceCouponType object.

3 calls to commerce_coupon_type_save()
commerce_coupon_type_disable in ./commerce_coupon.module
Disables a coupon type and set as inactive all the coupons from the type.
commerce_coupon_type_enable in ./commerce_coupon.module
Enables a coupon type.
commerce_coupon_ui_coupon_type_form_submit in includes/commerce_coupon_ui.forms.inc
Form API submit callback for the type form.

File

./commerce_coupon.module, line 334
Coupon System for Drupal Commerce.

Code

function commerce_coupon_type_save(CommerceCouponType $type, $reset = FALSE) {

  // Store the entity, must be done before they are configured
  $type
    ->save();

  // Configure the type
  commerce_coupon_type_configure($type->type, $reset);

  // Ensure the creation of the rules (components)
  entity_defaults_rebuild();
  return $type;
}