You are here

function uc_attribute_subject_option_delete in Ubercart 6.2

Same name and namespace in other branches
  1. 8.4 uc_attribute/uc_attribute.module \uc_attribute_subject_option_delete()
  2. 7.3 uc_attribute/uc_attribute.module \uc_attribute_subject_option_delete()

Deletes a product/class attribute option.

Parameters

$oid: The base attribute's option ID.

$type: Is this a product or a class?

$id: The product/class ID.

Return value

The Drupal SAVED_DELETED flag.

2 calls to uc_attribute_subject_option_delete()
uc_attribute_option_delete in uc_attribute/uc_attribute.module
Deletes an attribute option from the database.
uc_attribute_subject_delete in uc_attribute/uc_attribute.module
Deletes an attribute and all options associated with it.

File

uc_attribute/uc_attribute.module, line 1046

Code

function uc_attribute_subject_option_delete($oid, $type, $id = NULL, $adjustments = TRUE) {
  $sql = uc_attribute_type_info($type);

  // Base conditions, and an ID check if necessary.
  $conditions[] = "oid = %d";
  if ($id) {
    $conditions[] = "{$sql['id']} = {$sql['placeholder']}";
  }
  $conditions = implode(" AND ", $conditions);

  // Delete the option.
  db_query("DELETE FROM {$sql['opt_table']} WHERE {$conditions}", $oid, $id);

  // If this is a product, clean up the associated adjustments.
  if ($adjustments && $type == 'product') {
    uc_attribute_adjustments_delete(array(
      'aid' => uc_attribute_option_load($oid)->aid,
      'oid' => $oid,
      'nid' => $id,
    ));
  }
  return SAVED_DELETED;
}