You are here

function uc_attribute_priced_attributes in Ubercart 8.4

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

Gets the price affecting attributes for a product.

Parameters

int $nid: The nid of a product.

Return value

array Array of attribute ids that have price affecting options.

1 call to uc_attribute_priced_attributes()
_uc_attribute_alter_form in uc_attribute/uc_attribute.module
Helper function for uc_attribute_form_alter().

File

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

Code

function uc_attribute_priced_attributes($nid) {
  $connection = \Drupal::database();
  $aids = $connection
    ->query("SELECT DISTINCT (pa.aid) FROM {uc_product_attributes} pa INNER JOIN {uc_attribute_options} ao ON ao.aid = pa.aid INNER JOIN {uc_product_options} po ON (po.oid = ao.oid AND po.nid = pa.nid) WHERE pa.nid = :nid AND po.price <> :price AND pa.display <> :display", [
    ':nid' => $nid,
    ':price' => 0,
    ':display' => 0,
  ])
    ->fetchCol();
  return $aids;
}