You are here

function uc_attribute_subject_option_save in Ubercart 8.4

Same name and namespace in other branches
  1. 6.2 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.

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

\Drupal\Core\Database\StatementInterface|null A prepared statement, or NULL if the query is not valid.

1 call to uc_attribute_subject_option_save()
uc_attribute_subject_save in uc_attribute/uc_attribute.module
Saves a product/class attribute.

File

uc_attribute/uc_attribute.module, line 883
Ubercart Attribute module.

Code

function uc_attribute_subject_option_save(&$option, $type, $id) {
  $sql = uc_attribute_type_info($type);
  $connection = \Drupal::database();
  return $connection
    ->merge($sql['opt_table'])
    ->keys([
    $sql['id'] => $id,
    'oid' => $option->oid,
  ])
    ->fields([
    'cost' => $option->cost,
    'price' => $option->price,
    'weight' => $option->weight,
    'ordering' => $option->ordering,
  ])
    ->execute();
}