You are here

function commerce_recurring_order_load_recurring_line_items in Commerce Recurring Framework 7.2

Return all the line items that contain a recurring product in an order context.

Parameters

$order: Commerce order.

Return value

array of commerce line items that have recurring capabilities or empty array if none of the products from the order is recurring.

2 calls to commerce_recurring_order_load_recurring_line_items()
commerce_recurring_rules_get_recurring_line_items in ./commerce_recurring.rules.inc
Return the recurring products present inside an order.
commerce_recurring_rules_order_contains_recurring_product in ./commerce_recurring.rules.inc
Condition to check wether the order has some recurring products on it.

File

./commerce_recurring.module, line 497
Commerce recurring module file.

Code

function commerce_recurring_order_load_recurring_line_items($order) {
  if (empty($order->order_id)) {
    return array();
  }
  $recurring_entities = array();
  $order_wrapper = entity_metadata_wrapper('commerce_order', $order);
  foreach ($order_wrapper->commerce_line_items as $line_item_wrapper) {
    if (in_array($line_item_wrapper->type
      ->value(), commerce_product_line_item_types())) {
      $product = $line_item_wrapper->commerce_product
        ->value();
      if (commerce_recurring_product_is_recurring($product)) {
        $recurring_entities[$order->order_id][] = $line_item_wrapper
          ->value();
      }
    }
  }
  return $recurring_entities;
}