You are here

function commerce_gc_handler_area_add_transaction_form::render in Commerce GC 7

Render the area.

Overrides views_handler_area::render

File

includes/views/handlers/commerce_gc_handler_area_add_transaction_form.inc, line 9
Provides a simple add transaction form as an area

Class

commerce_gc_handler_area_add_transaction_form
@file Provides a simple add transaction form as an area

Code

function render($empty = FALSE) {
  if (user_access('create new giftcard transactions')) {
    foreach ($this->view->argument as $name => $argument) {
      if (count($argument->value) == 1) {
        $value = reset($argument->value);

        // Find some kind of argument we can use.
        if ($argument instanceof commerce_coupon_handler_argument_coupon_code) {
          $coupon = commerce_coupon_load_by_code($value);
        }
        else {
          if ($argument instanceof commerce_coupon_handler_argument_coupon_id) {
            $coupon = commerce_coupon_load($value);
          }
        }

        // TODO there is a problem with this going to the "all" argument.
        $form = drupal_get_form('commerce_gc_add_transaction_action_form_simple', $coupon->coupon_id);
        return drupal_render($form);
      }
    }
  }
}