You are here

function commerce_registration_product_has_registration_field in Commerce Registration 7.2

Same name and namespace in other branches
  1. 7.3 commerce_registration.module \commerce_registration_product_has_registration_field()

Checks if a product has a registration field attached.

Parameters

int $product_id The product id.:

Return value

boolean Whether a product has a registration field attached.

11 calls to commerce_registration_product_has_registration_field()
commerce_registration_add_to_cart_validate in ./commerce_registration.module
Custom validation handler for add to cart form. Checks if the product being added is available for registration before adding it to the cart. If it is not available, it is not added and a message is shown to the user.
commerce_registration_commerce_checkout_router in ./commerce_registration.module
Implements hook_commerce_checkout_router().
commerce_registration_form_alter in ./commerce_registration.module
Implements hook_form_alter().
commerce_registration_form_commerce_order_ui_order_form_alter in ./commerce_registration.module
Implements hook_form_FORM_ID_alter().
commerce_registration_information_checkout_form in includes/commerce_registration.checkout_pane.inc
Commerce checkout pane form builder callback.

... See full list

File

./commerce_registration.module, line 730
Commerce Registration module code.

Code

function commerce_registration_product_has_registration_field($product_id) {
  $product = commerce_product_load($product_id);
  $fields = field_read_fields(array(
    'type' => 'registration',
  ));
  foreach ($fields as $field) {
    if (isset($product->{$field['field_name']}) && !empty($product->{$field['field_name']}[LANGUAGE_NONE]['0']['registration_type'])) {
      return TRUE;
    }
  }
  return FALSE;
}