function uc_attribute_adjustments_delete in Ubercart 7.3
Same name and namespace in other branches
- 8.4 uc_attribute/uc_attribute.module \uc_attribute_adjustments_delete()
- 6.2 uc_attribute/uc_attribute.module \uc_attribute_adjustments_delete()
Deletes an attribute adjustment.
Parameters
array $fields: Fields used to build a condition to delete adjustments against. Fields currently handled are 'aid', 'oid', and 'nid'.
Return value
int The Drupal SAVED_DELETED flag.
3 calls to uc_attribute_adjustments_delete()
- UbercartAttributeTestCase::testAttributeAPI in uc_attribute/
tests/ uc_attribute.test - Tests the basic attribute API.
- uc_attribute_subject_delete in uc_attribute/
uc_attribute.module - Deletes an attribute and all options associated with it.
- uc_attribute_subject_option_delete in uc_attribute/
uc_attribute.module - Deletes a product/class attribute option.
File
- uc_attribute/
uc_attribute.module, line 1053 - Ubercart Attribute module.
Code
function uc_attribute_adjustments_delete(array $fields) {
// Build the serialized string to match against adjustments.
$match = '';
if (!empty($fields['aid'])) {
$match .= serialize((int) $fields['aid']);
}
if (!empty($fields['oid'])) {
$match .= serialize((string) $fields['oid']);
}
// Assemble the conditions and args for the SQL.
$query = db_delete('uc_product_adjustments');
// If we have to match aid or oid...
if ($match) {
$query
->condition('combination', '%' . db_like($match) . '%', 'LIKE');
}
// If we've got a node ID to match.
if (!empty($fields['nid'])) {
$query
->condition('nid', $fields['nid']);
}
// Delete what's necessary.
if ($query
->conditions()) {
$query
->execute();
}
return SAVED_DELETED;
}