You are here

function uc_attribute_subject_option_save in Ubercart 6.2

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

Saves a product/class attribute option.

Parameters

&$option: The product/class attribute option.

$type: Is this a product or a class?

$id: The product/class ID.

Return value

The integer result from drupal_write_record().

2 calls to uc_attribute_subject_option_save()
UbercartAttributeTestCase::testAttributeUIAttributeOptionsBulkEdit in uc_attribute/uc_attribute.test
Tests the "bulk edit attribute options" user interface.
uc_attribute_subject_save in uc_attribute/uc_attribute.module
Saves a product/class attribute.

File

uc_attribute/uc_attribute.module, line 1020

Code

function uc_attribute_subject_option_save(&$option, $type, $id) {
  $sql = uc_attribute_type_info($type);

  // Insert or update?
  $key = uc_attribute_subject_option_exists($option->oid, $type, $id) ? array(
    'oid',
    $sql['id'],
  ) : NULL;

  // Merge in the product/class attribute option's ID, and save.
  $option->{$type == 'product' ? 'nid' : 'pcid'} = $id;
  $result = drupal_write_record(trim($sql['opt_table'], '{}'), $option, $key);
  return $result;
}