You are here

function basic_cart_cart_form in Basic cart 7.3

Same name and namespace in other branches
  1. 7 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',
    );
  }

  // Total price.
  $form['total_price'] = array(
    '#markup' => t('Total price'),
    '#prefix' => '<div class="basic-cart-cart basic-cart-grid">',
    '#suffix' => '</div>',
    '#theme' => 'basic_cart_cart_total_price',
  );

  // Buttons.
  $form['buttons'] = array(
    // Make the returned array come back in tree form.
    '#tree' => TRUE,
    '#prefix' => '<div class="row"><div class="basic-cart-call-to-action cell">',
    '#suffix' => '</div></div>',
  );

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

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