You are here

function webform_conditional_operator_product_is_of_type in Commerce Webform 8

Same name and namespace in other branches
  1. 7.2 productfield.inc \webform_conditional_operator_product_is_of_type()

Webform conditionals comparison callback for product fields.

1 call to webform_conditional_operator_product_is_of_type()
webform_conditional_operator_product_is_not_of_type in ./productfield.inc
Webform conditionals comparison callback for product fields.
1 string reference to 'webform_conditional_operator_product_is_of_type'
_commerce_webform_conditional_operator_info in ./productfield.inc
Define conditional operators for productfields.

File

./productfield.inc, line 930

Code

function webform_conditional_operator_product_is_of_type($input_values, $rule_value) {
  $selected_products = _commerce_webform_get_selected_products_from_input_values($input_values);
  foreach ($selected_products as $product_id => $quantity) {
    if ($quantity > 0) {
      $product = commerce_product_load($product_id);
      if ($product->type == $rule_value) {
        return TRUE;
      }
    }
  }
  return FALSE;
}