You are here

function commerce_recurring_rules_order_contains_recurring in Commerce Recurring Framework 7

Condition callback: checks to see if a recurring product exists on an order

File

./commerce_recurring.rules.inc, line 306

Code

function commerce_recurring_rules_order_contains_recurring($order) {

  // If we actually received a valid order...
  if (!empty($order)) {
    $order_wrapper = entity_metadata_wrapper('commerce_order', $order);

    // Populate the array of the quantities of the products on the order.
    foreach ($order_wrapper->commerce_line_items as $delta => $line_item_wrapper) {
      $product = $line_item_wrapper->commerce_product
        ->value();
      if ($product->type == 'recurring') {
        return TRUE;
      }
    }
  }
  return FALSE;
}