You are here

function uc_recurring_product_recurring_renewal_pending in UC Recurring Payments and Subscriptions 7.2

Same name and namespace in other branches
  1. 6.2 modules/uc_recurring_product/uc_recurring_product.module \uc_recurring_product_recurring_renewal_pending()

On renewal we need to add a product to the order that matches the recurring fee.

Parameters

$order: Order Object.

$fee: Recurring fee Object.

File

modules/uc_recurring_product/uc_recurring_product.module, line 563
Add recurring payments/fees to a product. This is imlpemented through Ubercarts product features.

Code

function uc_recurring_product_recurring_renewal_pending(&$order, &$fee) {
  if ($fee->module != 'uc_recurring_product') {
    return;
  }

  // Set a single product - the recurring fee.
  $product = new stdClass();
  $product->order_id = $order->order_id;
  $product->nid = $fee->data['nid'];
  $product->model = $fee->data['model'];
  $product->title = !empty($fee->fee_title) ? $fee->fee_title : t('Renewal of product @model', array(
    '@model' => $product->model,
  ));
  $product->qty = !empty($fee->data['qty']) ? $fee->data['qty'] : 1;
  $product->price = $fee->fee_amount / $product->qty;

  // initialize these items to remove warnings
  $product->cost = 0;
  $product->manufacturer = '';
  $product->weight = 0;

  // Add a flag that this order is a recurring fee order, so it won't be
  // processed by uc_recurring_product_process_order().
  $product->data['recurring_fee'] = TRUE;
  $order->products[] = $product;
}