You are here

function uc_dropdown_attributes_dependency_type in Dropdown Attributes 7

Same name and namespace in other branches
  1. 8 uc_dropdown_attributes.module \uc_dropdown_attributes_dependency_type()
  2. 6 uc_dropdown_attributes.module \uc_dropdown_attributes_dependency_type()

Retrieve whether dependencies are defined by node or class.

Parameters

int $nid: Node id.

Return value

string 'node' for dependencies defined on the node level; 'class' for dependencies defined on the product class; otherwise, NULL.

7 calls to uc_dropdown_attributes_dependency_type()
UCDropdownAttributesTestCase::testClassAttributeDependency in tests/uc_dropdown_attributes.test
Test for dropdown attributes in product classes.
UCDropdownAttributesTestCase::testProductAttributeDependency in tests/uc_dropdown_attributes.test
Test for dropdown attributes in products.
uc_dropdown_attributes_form_alter in ./uc_dropdown_attributes.module
Implements hook_form_alter().
uc_dropdown_attributes_form_uc_order_edit_form_alter in ./uc_dropdown_attributes.module
Implements hook_form_FORM_ID_alter() for uc_order_edit_form().
uc_dropdown_attributes_product in ./dependent_dropdown.inc
Form constructor for the uc_dropdown_attributes_product form.

... See full list

File

./uc_dropdown_attributes.module, line 738
Show/hide attributes based on the values of other attributes.

Code

function uc_dropdown_attributes_dependency_type($nid) {
  $sql = 'SELECT COUNT(*) FROM {uc_dropdown_attributes} WHERE nid=:nid';
  $count = db_query($sql, array(
    ':nid' => $nid,
  ))
    ->fetchField();
  if ($count > 0) {
    return 'node';
  }
  $pcid = uc_dropdown_attributes_get_type($nid);
  $sql = 'SELECT COUNT(*) FROM {uc_dropdown_classes} WHERE pcid=:pcid';
  $count = db_query($sql, array(
    ':pcid' => $pcid,
  ))
    ->fetchField();
  if ($count > 0) {
    return 'class';
  }
  return NULL;
}