You are here

function commerce_node_checkout_process_element in Commerce Node Checkout 7

Element process callback to build the product selection form widget for a node.

1 string reference to 'commerce_node_checkout_process_element'
commerce_node_checkout_element_info in ./commerce_node_checkout.module
Implements hook_element_info().

File

./commerce_node_checkout.module, line 136
Provides core hooks and the like for the module

Code

function commerce_node_checkout_process_element($element) {

  // Get the available products for this node
  $products = commerce_node_checkout_get_node_type_product_list($element['#node_type']);

  // Add a selection for the product
  $element['commerce_node_checkout_product'] = array(
    '#type' => count($products) > 1 ? 'select' : 'radios',
    '#title' => t('Listing option'),
    '#options' => $products,
    '#description' => t('Select your desired listing option.'),
    '#default_value' => key($products),
    '#required' => TRUE,
    '#access' => !empty($products),
  );
  return $element;
}