You are here

function _webform_productfield_product_ids in Commerce Webform 7.2

Same name and namespace in other branches
  1. 8 productfield.inc \_webform_productfield_product_ids()

Get a list of all the product_ids available to choose from on a productfield.

Parameters

array $component: A webform productfield component

Return value

array An array of product ids. Note that if a product type is specified only, this will return an empty array.

2 calls to _webform_productfield_product_ids()
_webform_productfield_generate_options_list_for_component in ./productfield.inc
_webform_render_productfield in ./productfield.inc
Implements _webform_render_component().

File

./productfield.inc, line 847

Code

function _webform_productfield_product_ids($component) {
  $items = isset($component['extra']['items']) ? $component['extra']['items'] : array();
  $product_type = isset($component['extra']['product_type']) ? $component['extra']['product_type'] : '';
  $product_ids = array();

  // If a product type is set, load all the products for
  // that type.
  if (!empty($product_type)) {
    $product_ids = _webform_productfield_product_ids_from_type($product_type);
  }
  else {
    foreach ($items as $item) {
      $product_ids[] = $item['product_id'];
    }
  }
  return $product_ids;
}