function commerce_option_set_delete in Commerce Product Option 7.2
Same name and namespace in other branches
- 7 commerce_option.module \commerce_option_set_delete()
Delete a commerce option set. Make sure we also delete all commerce options using this bundle.
1 string reference to 'commerce_option_set_delete'
- commerce_option_entity_info in ./
commerce_option.module - Implements hook_entity_info().
File
- ./
commerce_option.module, line 411
Code
function commerce_option_set_delete($id) {
$option_set = commerce_option_set_load($id);
$bundle = $option_set->set_id;
$options = db_select('commerce_option', 'co')
->fields('co', array(
'option_id',
))
->condition('set_id', $bundle, '=')
->execute()
->fetchCol();
if (!empty($options)) {
entity_delete_multiple('commerce_option', $options);
}
// And finally delete the entity itself.
entity_get_controller('commerce_option_set')
->delete(array(
$id,
));
}