You are here

function commerce_product_types in Commerce Core 7

Returns an array of product type arrays keyed by type.

18 calls to commerce_product_types()
CommerceProductCRUDTestCase::testCommerceProductDefaultProducts in modules/product/tests/commerce_product.test
Ensure the default product types are created.
CommerceProductCRUDTestCase::testCommerceProductTypeCrud in modules/product/tests/commerce_product.test
Test the product type CRUD functions.
CommerceProductUIAdminTest::setUp in modules/product/tests/commerce_product_ui.test
Implementation of setUp().
CommerceProductUIAdminTest::testCommerceProductUIAccessProductTypes in modules/product/tests/commerce_product_ui.test
Test the access to the product types listing page.
CommerceProductUIAdminTest::testCommerceProductUIAddProductType in modules/product/tests/commerce_product_ui.test
Test adding a new product type.

... See full list

1 string reference to 'commerce_product_types'
commerce_product_types_reset in modules/product/commerce_product.module
Resets the cached list of product types.

File

modules/product/commerce_product.module, line 374
Defines the core Commerce product entity, including the entity itself, the bundle definitions (product types), and various API functions to manage products and interact with them through forms and autocompletes.

Code

function commerce_product_types() {

  // First check the static cache for a product types array.
  $product_types =& drupal_static(__FUNCTION__);

  // If it did not exist, fetch the types now.
  if (!isset($product_types)) {
    $product_types = array();

    // Find product types defined by hook_commerce_product_type_info().
    foreach (module_implements('commerce_product_type_info') as $module) {
      foreach (module_invoke($module, 'commerce_product_type_info') as $type => $product_type) {

        // Set the module each product type is defined by and revision handling
        // if they aren't set yet.
        $product_type += array(
          'module' => $module,
          'revision' => 1,
        );
        $product_types[$type] = $product_type;
      }
    }

    // Last allow the info to be altered by other modules.
    drupal_alter('commerce_product_type_info', $product_types);
  }
  return $product_types;
}