You are here

function commerce_invoice_load_by_order_id in Commerce Invoice 7

Loads an invoice by order ID

2 calls to commerce_invoice_load_by_order_id()
commerce_invoice_ui_access_by_order in ./commerce_invoice_ui.module
Checks invoice access based on order id.
commerce_invoice_ui_invoice_view_by_order in ./commerce_invoice_ui.module
Generate an array for rendering the given invoice, based on an order.

File

./commerce_invoice.module, line 88
Generates the invoice and allows you to display an invoice id in views

Code

function commerce_invoice_load_by_order_id($order_id) {
  $query = new EntityFieldQuery();
  $return = FALSE;
  $result = $query
    ->entityCondition('entity_type', 'commerce_invoice')
    ->propertyCondition('order_id', $order_id)
    ->execute();
  if ($result) {
    $invoice = array_keys($result['commerce_invoice']);
    $return = commerce_invoice_load(reset($invoice));
  }
  return $return;
}