You are here

function uc_product_is_product in Ubercart 8.4

Same name and namespace in other branches
  1. 5 uc_product/uc_product.module \uc_product_is_product()
  2. 6.2 uc_product/uc_product.module \uc_product_is_product()
  3. 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

mixed $node: Either a full node object/array, a node ID, or a node type.

Return value

bool TRUE or FALSE indicating whether or not a node type is a product node type.

29 calls to uc_product_is_product()
AddToCart::render in uc_product/src/Plugin/views/field/AddToCart.php
Renders the field.
BuyItNow::render in uc_product/src/Plugin/views/field/BuyItNow.php
Renders the field.
ProductAccessCheck::access in uc_product/src/Access/ProductAccessCheck.php
ProductTest::testProductClassForm in uc_product/tests/src/Functional/ProductTest.php
Tests making node types into products.
TaxRateForm::form in uc_tax/src/Form/TaxRateForm.php
Gets the actual form array to be built.

... See full list

3 string references to 'uc_product_is_product'
uc_product_views_data in uc_product/uc_product.views.inc
Implements hook_views_data().
views.view.uc_catalog.yml in uc_catalog/config/install/views.view.uc_catalog.yml
uc_catalog/config/install/views.view.uc_catalog.yml
views.view.uc_products.yml in uc_product/config/install/views.view.uc_products.yml
uc_product/config/install/views.view.uc_products.yml

File

uc_product/uc_product.module, line 708
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
      ->getType();
  }
  elseif (is_array($node)) {
    $type = $node['type'];
  }
  elseif (is_string($node)) {
    $type = $node;
  }
  else {

    // If no node type was found, go ahead and return FALSE.
    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());
}