function commerce_pricelist_entity_delete in Commerce Pricelist 7
Same name and namespace in other branches
- 8.2 commerce_pricelist.module \commerce_pricelist_entity_delete()
- 8 commerce_pricelist.module \commerce_pricelist_entity_delete()
Delete pricelist items when a pricelist is deleted.
Implements hook_entity_delete().
File
- ./
commerce_pricelist.module, line 528 - Implements the basic functionality required for price lists
Code
function commerce_pricelist_entity_delete($entity, $type) {
if ($type == 'commerce_pricelist_list') {
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'commerce_pricelist_item')
->propertyCondition('pricelist_id', $entity->list_id, '=');
$result = $query
->execute();
if (!empty($result['commerce_pricelist_item'])) {
commerce_pricelist_item_delete_multiple($result['commerce_pricelist_item']);
}
}
}