function uc_product_is_product in Ubercart 6.2
Same name and namespace in other branches
- 8.4 uc_product/uc_product.module \uc_product_is_product()
 - 5 uc_product/uc_product.module \uc_product_is_product()
 - 7.3 uc_product/uc_product.module \uc_product_is_product()
 
Determines whether or not a given node or node type is a product.
Parameters
$node: Either a full node object/array, a node ID, or a node type.
Return value
TRUE or FALSE indicating whether or not a node type is a product node type.
24 calls to uc_product_is_product()
- uc_attribute_nodeapi in uc_attribute/
uc_attribute.module  - Implements hook_nodeapi().
 - uc_attribute_product_access in uc_attribute/
uc_attribute.module  - Access callback for editing a product's attributes.
 - uc_attribute_product_option_access in uc_attribute/
uc_attribute.module  - Access callback for editing a product's options.
 - uc_cart_add_item in uc_cart/
uc_cart.module  - Adds an item to a user's cart.
 - uc_cart_nodeapi in uc_cart/
uc_cart.module  - Implements hook_nodeapi().
 
File
- uc_product/
uc_product.module, line 1641  - The product module for Ubercart.
 
Code
function uc_product_is_product($node) {
  // Load the node object if we received an integer as an argument.
  if (is_numeric($node)) {
    $node = node_load($node);
  }
  // Determine the node type based on the data type of $node.
  if (is_object($node)) {
    $type = $node->type;
  }
  elseif (is_array($node)) {
    $type = $node['type'];
  }
  elseif (is_string($node)) {
    $type = $node;
  }
  // If no node type was found, go ahead and return FALSE.
  if (!$type) {
    return FALSE;
  }
  // Return TRUE or FALSE depending on whether or not the node type is in the
  // product types array.
  return in_array($type, uc_product_types());
}