You are here

function commerce_gc_line_item_add_form in Commerce GC 7

File

./commerce_gc.module, line 530
Provides Giftcard coupon bundle, Giftcard Transaction entity and basic user interface elements.

Code

function commerce_gc_line_item_add_form($element, &$form_state) {
  $form['code'] = array(
    '#type' => 'textfield',
    '#title' => t('Giftcard code'),
    '#description' => t('Enter a giftcard code to redeem.'),
    '#required' => TRUE,
  );
  $form['amount'] = array(
    '#type' => 'textfield',
    '#title' => t('Amount') . ' (' . commerce_default_currency() . ')',
    '#description' => t('Enter an amount to charge this giftcard.'),
  );

  // We do not allow the line item terminal to trigger transaction inserts if
  // the order is in the shopping cart state because orders are not supposed to
  // record transactions until checkout is complete.
  if (commerce_cart_order_is_cart($form_state['commerce_order'])) {
    $form['no_transaction'] = array(
      '#type' => 'markup',
      '#prefix' => '<div>',
      '#markup' => t('Since the order is in the shopping cart state, adding this giftcard line item will not generate a transaction.
        !link', array(
        '!link' => l('Manage giftcard transactions directly', 'admin/commerce/coupons/giftcards'),
      )),
      '#suffix' => '</div>',
    );
  }
  return $form;
}