You are here

function uc_recurring_save_extensions in UC Recurring Payments and Subscriptions 6.2

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

Save a set of extensions.

Parameters

$extensions: String of comma seperated day values to extend the extension.

$extend_seconds: The number of seconds to extend the order by.

1 call to uc_recurring_save_extensions()
uc_recurring_payment_form_save_extensions in ./uc_recurring.admin.inc
Saves the extension options.

File

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

Code

function uc_recurring_save_extensions($extensions, $fee_id = NULL) {
  db_query("DELETE FROM {uc_recurring_extensions} WHERE pfid IS NULL");
  $extend = explode(',', $extensions);
  $count = 0;
  foreach ($extend as $days_to_extend) {
    $seconds = $days_to_extend * (24 * 60 * 60);
    db_query("INSERT INTO {uc_recurring_extensions} (rebill_attempt, time_to_extend) VALUES (%d, %d)", $count, $seconds);
    $count++;
  }

  // Last extension set extension to 0 to expire.
  db_query("INSERT INTO {uc_recurring_extensions} (rebill_attempt, time_to_extend) VALUES (%d, 0)", $count);
}