You are here

function basic_cart_cart_form in Basic cart 7

Same name and namespace in other branches
  1. 7.3 basic_cart.cart.inc \basic_cart_cart_form()
  2. 7.2 basic_cart.cart.inc \basic_cart_cart_form()

Shopping cart form.

1 string reference to 'basic_cart_cart_form'
basic_cart_cart in ./basic_cart.cart.inc
Callback function for cart listing.

File

./basic_cart.cart.inc, line 23
Basic cart shopping cart implementation functions.

Code

function basic_cart_cart_form() {

  // Getting the shopping cart.
  $cart = basic_cart_get_cart();

  // And now the form.
  $form['cartcontents'] = array(
    // Make the returned array come back in tree form.
    '#tree' => TRUE,
    '#prefix' => '<div class="basic-cart-cart basic-cart-grid">',
    '#suffix' => '</div>',
  );

  // Cart elements.
  foreach ($cart as $nid => $node) {
    $form['cartcontents'][$nid] = array(
      '#type' => 'textfield',
      '#size' => 1,
      '#default_value' => $node->basic_cart_quantity,
      '#theme' => 'basic_cart_render_cart_element',
    );
  }

  // Update button.
  $form['update'] = array(
    '#type' => 'submit',
    '#value' => t('Update'),
  );

  // Checkout button.
  $form['checkout'] = array(
    '#type' => 'submit',
    '#value' => t('Checkout'),
  );
  return $form;
}