You are here

function uc_attribute_option_save in Ubercart 8.4

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

Saves an attribute object to the database.

Parameters

object $option: The attribute option object to save.

Return value

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

6 calls to uc_attribute_option_save()
AttributeTest::testAttributeUiAttributeOptions in uc_attribute/tests/src/Functional/AttributeTest.php
Tests the attribute options user interface.
AttributeTest::testAttributeUiAttributeOptionsDelete in uc_attribute/tests/src/Functional/AttributeTest.php
Tests the "delete attribute option" user interface.
AttributeTest::testAttributeUiAttributeOptionsEdit in uc_attribute/tests/src/Functional/AttributeTest.php
Tests the "edit attribute options" user interface.
AttributeTestTrait::createAttributeOption in uc_attribute/tests/src/Traits/AttributeTestTrait.php
Creates an attribute option.
InclusiveTaxTest::testProductKitAttributes in uc_tax/tests/src/Functional/InclusiveTaxTest.php
Test inclusive taxes with product kit attributes.

... See full list

File

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

Code

function uc_attribute_option_save(&$option) {
  $fields = [
    'aid' => $option->aid,
    'name' => $option->name,
    'cost' => $option->cost,
    'price' => $option->price,
    'weight' => $option->weight,
    'ordering' => $option->ordering,
  ];
  $connection = \Drupal::database();
  if (empty($option->oid)) {
    $option->oid = $connection
      ->insert('uc_attribute_options')
      ->fields($fields)
      ->execute();
    return Merge::STATUS_INSERT;
  }
  else {
    return $connection
      ->merge('uc_attribute_options')
      ->key('oid', $option->oid)
      ->fields($fields)
      ->execute();
  }
}