You are here

function _commerce_coupon_load_argument_order in Commerce Coupon 7.2

Get the argument order if present.

Parameters

views_handler $handler: A views handler.

Return value

bool|object Either an order entity or FALSE.

2 calls to _commerce_coupon_load_argument_order()
commerce_coupon_handler_field_coupon_order_remove::render in includes/views/handlers/commerce_coupon_handler_field_coupon_order_remove.inc
Overrides parent::render().
commerce_coupon_handler_field_discount_value_display::render in includes/views/handlers/commerce_coupon_handler_field_discount_value_display.inc
Overrides parent::render().

File

includes/views/commerce_coupon.views.inc, line 111
Coupon views extra data.

Code

function _commerce_coupon_load_argument_order(views_handler $handler) {

  // Determine if there is an order id argument. If multiple are present, use
  // the first found.
  if (isset($handler->view->argument)) {
    foreach ($handler->view->argument as $alias => $argument) {
      if ($argument instanceof commerce_order_handler_argument_order_order_id) {
        $order_id = (int) $handler->view->argument[$alias]->value[0];
        $order = commerce_order_load($order_id);
      }
    }
  }
  return isset($order) ? $order : FALSE;
}