function commerce_coupon_ui_coupon_type_delete_form_wrapper in Commerce Coupon 7
Form callback wrapper: confirmation form for deleting a coupon type.
Parameters
$coupon: The coupon type object.
1 string reference to 'commerce_coupon_ui_coupon_type_delete_form_wrapper'
- commerce_coupon_ui_menu in ./
commerce_coupon_ui.module - Implements hook_menu().
File
- ./
commerce_coupon_ui.module, line 407 - Coupon User Interface for Drupal Commerce
Code
function commerce_coupon_ui_coupon_type_delete_form_wrapper(CommerceCouponType $coupon_type) {
// Add the breadcrumb for the form's location.
commerce_coupon_ui_set_breadcrumb(TRUE);
// Don't allow deletion of coupon types that have coupons already.
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'commerce_coupon', '=')
->entityCondition('bundle', $coupon_type->type, '=')
->count();
$count = $query
->execute();
if ($count > 0) {
drupal_set_title(t('Cannot delete the %label coupon type', array(
'%name' => $coupon_type->label,
)), PASS_THROUGH);
return format_plural($count, 'There is 1 coupon of this type. It cannot be deleted.', 'There are @count coupons of this type. It cannot be deleted.');
}
// Include the forms file from the Coupon module.
module_load_include('inc', 'commerce_coupon_ui', 'includes/commerce_coupon_ui.forms');
return drupal_get_form('commerce_coupon_ui_coupon_type_delete_form', $coupon_type);
}