You are here

function commerce_recurring_load_payments_due in Commerce Recurring Framework 7

Rules action callback: Load orders

File

./commerce_recurring.rules.inc, line 358

Code

function commerce_recurring_load_payments_due() {
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', 'commerce_order');
  $query
    ->entityCondition('bundle', 'recurring_order');
  $now = new DateObject('now');
  $query
    ->fieldCondition('commerce_recurring_payment_due', 'value', $now
    ->format('U'), '<=');
  $query
    ->fieldCondition('commerce_recurring_payment', 'value', 0, '=');
  $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(),
  );
}