You are here

function commerce_recurring_load_recurring in Commerce Recurring Framework 7

Rules action callback: Load orders

File

./commerce_recurring.rules.inc, line 341

Code

function commerce_recurring_load_recurring() {
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', 'commerce_order');
  $query
    ->entityCondition('bundle', 'commerce_order');
  $now = new DateObject('now');
  $query
    ->fieldCondition('commerce_recurring_next_due', 'value', $now
    ->format('U'), '<=');
  $query
    ->range(0, variable_get('commerce_recurring_batch_process', 20));
  $results = $query
    ->execute();
  if (!empty($results['commerce_order'])) {
    return array(
      'orders' => commerce_order_load_multiple(array_keys($results['commerce_order'])),
    );
  }
  return array(
    'orders' => array(),
  );
}