You are here

function uc_product_kit_buy_it_now_form in Ubercart 7.3

Same name and namespace in other branches
  1. 5 uc_product_kit/uc_product_kit.module \uc_product_kit_buy_it_now_form()
  2. 6.2 uc_product_kit/uc_product_kit.module \uc_product_kit_buy_it_now_form()

Add-to-cart button with any extra fields.

See also

uc_product_kit_buy_it_now_form_validate()

uc_product_kit_buy_it_now_form_submit()

1 string reference to 'uc_product_kit_buy_it_now_form'
uc_product_kit_forms in uc_product_kit/uc_product_kit.module
Implements hook_forms().

File

uc_product_kit/uc_product_kit.module, line 836
The product kit module for Ubercart.

Code

function uc_product_kit_buy_it_now_form($form, &$form_state, $node) {
  $form['nid'] = array(
    '#type' => 'hidden',
    '#value' => $node->nid,
  );
  if ($node->type == 'product_kit') {
    $form['products'] = array(
      '#tree' => TRUE,
    );
    foreach ($node->products as $i => $product) {
      $form['products'][$i] = array(
        '#title' => check_plain($product->title),
      );
      $form['products'][$i]['nid'] = array(
        '#type' => 'hidden',
        '#value' => $product->nid,
      );
      $form['products'][$i]['qty'] = array(
        '#type' => 'hidden',
        '#value' => $product->qty,
      );
    }
  }
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Add to cart'),
    '#id' => 'edit-submit-' . $node->nid,
    '#attributes' => array(
      'class' => array(
        'list-add-to-cart',
      ),
    ),
  );
  uc_form_alter($form, $form_state, __FUNCTION__);
  return $form;
}