You are here

function commerce_extra_panes_entity_update in Commerce extra panes 7

Implements hook_entity_update().

File

./commerce_extra_panes.module, line 175
Module file for Drupal Commerce Extra panes.

Code

function commerce_extra_panes_entity_update($entity, $type) {
  list($id) = entity_extract_ids($type, $entity);
  $panes = commerce_extra_panes_get_panes($id, $type);
  $extra_pane = reset($panes);
  if (!empty($extra_pane) && !empty($extra_pane->extra_id) && !$entity->status) {

    // Disable the pane.
    $affected_rows = db_update('commerce_extra_panes')
      ->fields(array(
      'status' => 0,
    ))
      ->condition('extra_id', $extra_pane->extra_id)
      ->condition('extra_type', $type)
      ->execute();
    if ($affected_rows) {
      drupal_set_message(t('Corresponding Commerce extra pane was disabled.'), 'warning');
    }
  }
}