[ Index ]
 

Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/includes/functions/ -> specials.php (source)

   1  <?php
   2  /**

   3   * product-specials functions

   4   *

   5   * @package functions

   6   * @copyright Copyright 2003-2005 Zen Cart Development Team

   7   * @copyright Portions Copyright 2003 osCommerce

   8   * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0

   9   * @version $Id: specials.php 2618 2005-12-20 00:35:47Z drbyte $

  10   */
  11  
  12  ////

  13  // Set the status of a product on special

  14    function zen_set_specials_status($specials_id, $status) {
  15      global $db;
  16      $sql = "update " . TABLE_SPECIALS . "
  17              set status = '" . $status . "', date_status_change = now()
  18              where specials_id = '" . (int)$specials_id . "'";
  19  
  20      return $db->Execute($sql);
  21     }
  22  
  23  ////

  24  // Auto expire products on special

  25    function zen_expire_specials() {
  26      global $db;
  27  
  28      $specials_query = "select specials_id, products_id
  29                         from " . TABLE_SPECIALS . "
  30                         where status = '1'
  31                         and ((now() >= expires_date and expires_date != '0001-01-01')
  32                         or (now() < specials_date_available and specials_date_available != '0001-01-01'))";
  33  
  34      $specials = $db->Execute($specials_query);
  35  
  36      if ($specials->RecordCount() > 0) {
  37        while (!$specials->EOF) {
  38          zen_set_specials_status($specials->fields['specials_id'], '0');
  39          zen_update_products_price_sorter($specials->fields['products_id']);
  40          $specials->MoveNext();
  41        }
  42      }
  43    }
  44  
  45  ////

  46  // Auto start products on special

  47    function zen_start_specials() {
  48      global $db;
  49  
  50  // turn on special if active

  51      $specials_query = "select specials_id, products_id
  52                         from " . TABLE_SPECIALS . "
  53                         where status = '0'
  54                         and (((specials_date_available <= now() and specials_date_available != '0001-01-01') and (expires_date >= now()))
  55                         or ((specials_date_available <= now() and specials_date_available != '0001-01-01') and (expires_date = '0001-01-01'))
  56                         or (specials_date_available = '0001-01-01' and expires_date >= now()))
  57                         ";
  58  
  59      $specials = $db->Execute($specials_query);
  60  
  61      if ($specials->RecordCount() > 0) {
  62        while (!$specials->EOF) {
  63          zen_set_specials_status($specials->fields['specials_id'], '1');
  64          zen_update_products_price_sorter($specials->fields['products_id']);
  65          $specials->MoveNext();
  66        }
  67      }
  68  
  69  // turn off special if not active yet

  70      $specials_query = "select specials_id, products_id
  71                         from " . TABLE_SPECIALS . "
  72                         where status = '1'
  73                         and (now() < specials_date_available and specials_date_available != '0001-01-01')
  74                         ";
  75  
  76      $specials = $db->Execute($specials_query);
  77  
  78      if ($specials->RecordCount() > 0) {
  79        while (!$specials->EOF) {
  80          zen_set_specials_status($specials->fields['specials_id'], '0');
  81          zen_update_products_price_sorter($specials->fields['products_id']);
  82          $specials->MoveNext();
  83        }
  84      }
  85    }
  86  ?>


Généré le : Mon Nov 26 16:45:43 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics