You are here

function uc_recurring_uc_checkout_complete in UC Recurring Payments and Subscriptions 6.2

Same name and namespace in other branches
  1. 7.2 uc_recurring.module \uc_recurring_uc_checkout_complete()

Implementation of hook_uc_checkout_complete().

This function is require to complete recurring orders for anonymous purchases as the uid is not set until the order has completed checkout.

File

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

Code

function uc_recurring_uc_checkout_complete($order, $account) {
  $fees = uc_recurring_get_fees($order);
  foreach ($fees as $fee) {
    if ($fee->uid == 0) {

      // check for anonymous uid
      $fee->uid = $order->uid;
      uc_recurring_fee_user_save($fee);
      $result = db_result(db_query("SELECT COUNT(*) FROM {uc_payment_receipts} WHERE order_id = '%d'", $order->order_id));
      if ($result) {
        db_query("UPDATE {uc_payment_receipts} SET uid = '%d' WHERE order_id='%d'", $order->uid, $order->order_id);
      }
    }
  }
}