You are here

function commerce_option_set_delete_form_wrapper in Commerce Product Option 7

Form callback wrapper: confirmation form for deleting a option set.

Parameters

$set_id: The machine-name of the option set being created or edited by this form or a full option set array.

See also

commerce_option_set_delete_form()

File

./commerce_option.module, line 406

Code

function commerce_option_set_delete_form_wrapper($set_id) {
  if (is_array($set_id)) {
    $option_set = $set_id;
  }
  else {
    $option_set = commerce_option_set_load($set_id);
  }

  // Add the breadcrumb for the form's location.
  commerce_option_breadcrumb(TRUE);

  // Return a message if the option set is not governed by Product UI.
  if ($option_set['module'] != 'commerce_option') {
    return t('This option set cannot be deleted, because it is not defined by the Option module.');
  }

  // Don't allow deletion of option set that have options defined.
  if (($count = db_query("SELECT option_id FROM {commerce_option} WHERE set = :set", array(
    ':set' => $option_set['set_id'],
  ))
    ->rowCount()) > 0) {
    drupal_set_title(t('Cannot delete the %name option set', array(
      '%name' => $option_set['name'],
    )), PASS_THROUGH);
    return format_plural($count, 'There is 1 option of this option set. It cannot be deleted.', 'There are @count options of this option set. It cannot be deleted.');
  }
  module_load_include('inc', 'commerce_option', 'includes/commerce_option_set.forms');
  return drupal_get_form('commerce_option_set_delete_form', $option_set);
}