You are here

function uc_recurring_uc_checkout_complete in UC Recurring Payments and Subscriptions 7.2

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

Implements 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 320
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) {

    // Check for anonymous users.
    if ($fee->uid == 0) {
      $fee->uid = $order->uid;
      uc_recurring_fee_user_save($fee);
      $has_rows = (bool) db_query_range('SELECT 1 FROM {uc_payment_receipts} WHERE order_id = :order_id', 0, 1, array(
        ':order_id' => $order->order_id,
      ))
        ->fetchField();
      if ($has_rows) {
        db_update('uc_payment_receipts')
          ->fields(array(
          'uid' => $order->uid,
        ))
          ->condition('order_id', $order->order_id)
          ->execute();
      }
    }
  }
}