You are here

function commerce_cpc_coupon_pane in Commerce Cart Pane 7

Coupon cart pane callback

1 string reference to 'commerce_cpc_coupon_pane'
commerce_cpc_commerce_cp_info in modules/coupon/commerce_cpc.module
Implements hook_commerce_cp_info().

File

modules/coupon/commerce_cpc.module, line 54

Code

function commerce_cpc_coupon_pane($form, $form_state, $cart_order, $pane_weight) {
  $form_pane = array();
  $form_pane['coupon'] = array(
    '#type' => 'container',
    '#weight' => $pane_weight,
    '#prefix' => '<div class="commerce_coupon">',
    '#suffix' => '</div>',
  );
  $form_pane['coupon']['coupon_code'] = array(
    '#type' => 'textfield',
    '#title' => t('Coupon Code'),
    '#description' => t('Enter your coupon code here.'),
    '#size' => 16,
  );
  $form_pane['coupon']['coupon_add'] = array(
    '#type' => 'submit',
    '#value' => t('Add coupon'),
    '#submit' => array(
      'commerce_cpc_coupon_add_form_submit',
    ),
  );

  // If there's at least one coupon has been attached to an order
  if (isset($cart_order->commerce_coupons) && !empty($cart_order->commerce_coupons)) {

    // take a view table from commerce_coupon module
    module_load_include('inc', 'commerce_coupon', 'includes/commerce_coupon.checkout_pane');
    $table = commerce_coupon_pane_review(NULL, NULL, NULL, $cart_order);
    $form_pane['coupon']['coupons_table'] = array(
      '#type' => 'markup',
      '#markup' => $table,
    );
  }
  return $form_pane;
}