You are here

function uc_recurring_find_fees in Ubercart 5

Returns an array of recurring fees associated with any product on an order.

Parameters

$order: The order object in question.

Return value

An array of recurring fee objects containing all their data from the DB.

3 calls to uc_recurring_find_fees()
uc_recurring_form_alter in payment/uc_recurring/uc_recurring.module
Implementation of hook_form_alter().
uc_recurring_order in payment/uc_recurring/uc_recurring.module
Implementation of hook_order().
uc_recurring_order_view_update_form_submit in payment/uc_recurring/uc_recurring.module

File

payment/uc_recurring/uc_recurring.module, line 1009
Allows you to add a recurring fee to a product/SKU to handle subscription type services.

Code

function uc_recurring_find_fees($order) {
  if (!is_array($order->products) || count($order->products) == 0) {
    return array();
  }
  $models = array();
  $nids = array();
  foreach ((array) $order->products as $product) {
    $nids[] = $product->nid;
    $models[] = check_plain($product->model);
  }
  $fees = array();
  $result = db_query("SELECT rp.*, nid FROM {uc_recurring_products} AS rp LEFT JOIN {uc_product_features} AS pf ON rp.pfid = pf.pfid WHERE rp.model IN ('" . implode("', '", $models) . "') OR (rp.model = '' AND pf.nid IN ('" . implode("', '", $nids) . "'))");
  while ($fee = db_fetch_object($result)) {
    $fees[] = $fee;
  }
  return $fees;
}