[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/includes/modules/ -> new_products.php (source)

   1  <?php
   2  /*

   3  $Id: new_products.php 3 2006-05-27 04:59:07Z user $

   4  

   5    osCMax Power E-Commerce

   6    http://oscdox.com

   7  

   8    Copyright 2008 osCMax

   9  

  10    Released under the GNU General Public License

  11  */
  12  ?>
  13  <!-- new_products //-->
  14  <?php
  15  
  16  // BOF: MOD - Separate Pricing per Customer

  17  //  $info_box_contents = array();

  18    $box_content = array();
  19  //  $info_box_contents[] = array('text' => sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')));

  20    $box_content[] = array('align' => 'left', 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCTS_NEW) . '" class="headerNavigation">' . sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B') . '</a>'));
  21  //  new contentBoxHeading($info_box_contents);

  22    new infoBoxHeading($box_content, false, false, tep_href_link(FILENAME_PRODUCTS_NEW));
  23  
  24    if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
  25  //  $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

  26      $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, p.products_price as products_price from " . TABLE_PRODUCTS . " p where products_status = '1' and month(p.products_date_added) = month(now()) order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS); 
  27    } else {
  28  //  $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

  29      $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, p.products_price as products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' and month(p.products_date_added) = month(now()) order by p.products_date_added desc limit ". MAX_DISPLAY_NEW_PRODUCTS);
  30    }
  31  
  32  // global variable (session) $sppc_customer_group_id -> local variable customer_group_id

  33    if(!tep_session_is_registered('sppc_customer_group_id')) { 
  34    $customer_group_id = '0';
  35    } else {
  36     $customer_group_id = $sppc_customer_group_id;
  37    }
  38   
  39    if (($no_of_new_products = tep_db_num_rows($new_products_query)) > 0) {
  40        while ($_new_products = tep_db_fetch_array($new_products_query)) {
  41      $new_products[] = $_new_products;
  42      $list_of_prdct_ids[] = $_new_products['products_id'];
  43      } 
  44  
  45  $select_list_of_prdct_ids = "products_id = '".$list_of_prdct_ids[0]."' ";
  46    if ($no_of_new_products > 1) {
  47     for ($n = 1 ; $n < count($list_of_prdct_ids) ; $n++) {
  48     $select_list_of_prdct_ids .= "or products_id = '".$list_of_prdct_ids[$n]."' ";   
  49     }
  50  }
  51  // get all customers_group_prices for products with the particular customer_group_id

  52  // however not necessary for customer_group_id = 0

  53  if ($customer_group_id != '0') {
  54    $pg_query = tep_db_query("select pg.products_id, customers_group_price as price from " . TABLE_PRODUCTS_GROUPS . " pg where (".$select_list_of_prdct_ids.") and pg.customers_group_id = '".$customer_group_id."'");
  55      while ($pg_array = tep_db_fetch_array($pg_query)) {
  56      $new_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['price'], 'specials_new_products_price' => '');
  57      }
  58  
  59     for ($x = 0; $x < $no_of_new_products; $x++) {
  60  // replace products prices with those from customers_group table

  61          if(!empty($new_prices)) {
  62          for ($i = 0; $i < count($new_prices); $i++) {
  63              if( $new_products[$x]['products_id'] == $new_prices[$i]['products_id'] ) {
  64              $new_products[$x]['products_price'] = $new_prices[$i]['products_price'];
  65              }
  66          }
  67      } // end if(!empty($new_prices)

  68     } // end for ($x = 0; $x < $no_of_products_new; $x++)

  69  } // end if ($customer_group_id != '0')

  70  
  71  // an extra query is needed for all the specials

  72      $specials_query = tep_db_query("select products_id, specials_new_products_price from " . TABLE_SPECIALS . " where (".$select_list_of_prdct_ids.") and status = '1' and customers_group_id = '" .$customer_group_id. "' ");
  73      while ($specials_array = tep_db_fetch_array($specials_query)) {
  74      $new_s_prices[] = array ('products_id' => $specials_array['products_id'], 'specials_new_products_price' => $specials_array['specials_new_products_price']);
  75      }
  76  
  77  // replace products_price with the correct specials_new_products_price

  78  if(!empty($new_s_prices)) {
  79      for ($x = 0; $x < $no_of_new_products; $x++) { 
  80          for ($i = 0; $i < count($new_s_prices); $i++) {
  81              if( $new_products[$x]['products_id'] == $new_s_prices[$i]['products_id'] ) {
  82              $new_products[$x]['products_price'] = $new_s_prices[$i]['specials_new_products_price'];
  83              }
  84             }
  85         } 
  86      } // // end if(!empty($new_s_prices)

  87  
  88    $row = 0;
  89    $col = 0;
  90  //  $info_box_contents = array();

  91    $box_content = array();
  92  
  93  //  while ($new_products = tep_db_fetch_array($new_products_query)) {

  94      for ($x = 0; $x < $no_of_new_products; $x++) {
  95      $new_products[$x]['products_name'] = tep_get_products_name($new_products[$x]['products_id']);
  96  
  97      $box_content[$row][$col] = array('align' => 'center',
  98                                             'params' => 'class="smallText" width="33%" valign="top"',
  99                                             'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . DYNAMIC_MOPICS_THUMBS_DIR . $new_products[$x]['products_image'], $new_products[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products[$x]['products_id']) . '">' . $new_products[$x]['products_name'] . '</a><br>' . $currencies->display_price($new_products[$x]['products_price'], tep_get_tax_rate($new_products[$x]['products_tax_class_id'])));
 100  
 101      $col ++;
 102      if ($col > 2) {
 103        $col = 0;
 104        $row ++;
 105      }
 106     } // end for ($x = 0; $x < $no_of_new_products; $x++)

 107   } //  end if (($no_of_new_products = tep_db_num_rows($new_products_query)) > 0)

 108    new contentBox($box_content);
 109  // EOF: MOD - Separate Pricing per Customer

 110  ?>
 111  <!-- new_products_eof //-->


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7