You are here

function uc_cart_cron in Ubercart 6.2

Same name and namespace in other branches
  1. 8.4 uc_cart/uc_cart.module \uc_cart_cron()
  2. 5 uc_cart/uc_cart.module \uc_cart_cron()
  3. 7.3 uc_cart/uc_cart.module \uc_cart_cron()

Implements hook_cron().

File

uc_cart/uc_cart.module, line 286

Code

function uc_cart_cron() {

  // Empty anonymous carts.
  $time = strtotime(variable_get('uc_cart_anon_duration', '4') . ' ' . variable_get('uc_cart_anon_unit', 'hours') . ' ago');
  $result = db_query("SELECT DISTINCT cart_id FROM {uc_cart_products} WHERE changed <= %d AND CHAR_LENGTH(cart_id) >= 22", $time);
  while ($row = db_fetch_object($result)) {
    uc_cart_empty($row->cart_id);
  }

  // Empty authenticated carts.
  $time = strtotime(variable_get('uc_cart_auth_duration', '1') . ' ' . variable_get('uc_cart_auth_unit', 'years') . ' ago');
  $result = db_query("SELECT DISTINCT cart_id FROM {uc_cart_products} WHERE changed <= %d AND CHAR_LENGTH(cart_id) < 22", $time);
  while ($row = db_fetch_object($result)) {
    uc_cart_empty($row->cart_id);
  }
}