function _webform_productfield_product_ids in Commerce Webform 8
Same name and namespace in other branches
- 7.2 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()
- commerce_webform_conditional_product_select in ./
productfield.inc - Webform conditional form callback.
- _webform_render_productfield in ./
productfield.inc - Implements _webform_render_component().
File
- ./
productfield.inc, line 733
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;
}