function uc_attribute_subject_option_delete in Ubercart 8.4
Same name and namespace in other branches
- 6.2 uc_attribute/uc_attribute.module \uc_attribute_subject_option_delete()
 - 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.
string $type: The type of attribute: 'product' or 'class'. Any other type will fetch a base attribute.
int $id: The product/class ID.
Return value
int 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 915  - Ubercart Attribute module.
 
Code
function uc_attribute_subject_option_delete($oid, $type, $id = NULL, $adjustments = TRUE) {
  $sql = uc_attribute_type_info($type);
  // Delete the option.
  $connection = \Drupal::database();
  $query = $connection
    ->delete($sql['opt_table'])
    ->condition('oid', $oid);
  // Base conditions, and an ID check if necessary.
  if ($id) {
    $query
      ->condition($sql['id'], $id);
  }
  $query
    ->execute();
  // If this is a product, clean up the associated adjustments.
  if ($adjustments && $type == 'product') {
    uc_attribute_adjustments_delete([
      'aid' => uc_attribute_option_load($oid)->aid,
      'oid' => $oid,
      'nid' => $id,
    ]);
  }
  return SAVED_DELETED;
}