You are here

function commerce_product_can_delete in Commerce Core 7

Determines whether or not the give product can be deleted.

Parameters

$product: The product to be checked for deletion.

Return value

Boolean indicating whether or not the product can be deleted.

1 call to commerce_product_can_delete()
CommerceProductEntityController::delete in modules/product/includes/commerce_product.controller.inc
Deletes multiple products by ID.

File

modules/product/commerce_product.module, line 562
Defines the core Commerce product entity, including the entity itself, the bundle definitions (product types), and various API functions to manage products and interact with them through forms and autocompletes.

Code

function commerce_product_can_delete($product) {

  // Return FALSE if the given product does not have an ID; it need not be
  // deleted, which is functionally equivalent to cannot be deleted as far as
  // code depending on this function is concerned.
  if (empty($product->product_id)) {
    return FALSE;
  }

  // If any module implementing hook_commerce_product_can_delete() returns FALSE
  // the product cannot be deleted. Return TRUE if none return FALSE.
  return !in_array(FALSE, module_invoke_all('commerce_product_can_delete', $product));
}