RE: Specify product quantity for an attribute

freezehell <[email protected]>
Newsgroups gmane.comp.web.oscommerce.features
Message-ID <1332ac5d33c2271bb0d72c7dc753916c@osCommerce-Forums>
This message was sent from: Features
http://forums.oscommerce.com/viewtopic.php?p=188983#188983
----------------------------------------------------------------

WORKS WITH 2.2CVS and MS1
I finally got qtpro to work perfectly. When SPECIAL is set to YES, stock check is done from the original stock table. This is needed if you dont track inventory based on the main product. Eg. memory upgrade and so on.

When SPECIAL is set to NO, stock check is done from PRODUCT_STOCK table.

Checkout_Shipping is also modded so that if you disallow out of stock checkout, it will redirect back to shopping cart even for attributes products.

PERFECT!!! well almost... 

Check it out here: http://wire.homeip.net:8880/catalog/ 
Check out the Uniform and canon fx3 fax supplies.

Most important MOD:
// Check if the required stock is available
// If insufficent stock is available return an out of stock message
  function tep_check_stock_new($products_id, $products_attibutes, $products_quantity) 
  {
    if (preg_match("/^(\d+)/",$products_id,$m)) $products_id=$m[1];
ksort($products_attibutes);
    $arr1=array();
    while(list($v1,$v2)=each($products_attibutes))
    {
      $arr1[]=$v1;
    }
    $arr1=implode(",",$arr1);
    $q=tep_db_query("select products_options_id as id,special from products_options where products_options_id in ($arr1) and language_id='".(int)$languages_id."'");
    while($rec=tep_db_fetch_array($q))
    {
      $special[$rec[id]]=$rec[special];
    }
    $attr=array();
    reset($products_attibutes);
    while(list($v1,$v2)=each($products_attibutes))
    {
      if (!$special[$v1]) $attr[]="$v1-$v2";

    }
    $attr=implode(",",$attr);

    $q=tep_db_query("select products_stock_quantity as quantity from products_stock where products_id='". (int)$products_id . "' and products_stock_attributes='$attr'");
    if (tep_db_num_rows($q))
    { 
      $rec=tep_db_fetch_array($q);
      $quantity=$rec[quantity];
    }
    else
    {
    $quantity = tep_get_products_stock($products_id);
    }
    $stock_left=$quantity-$products_quantity;
    $out_of_stock = '';
    if ($stock_left < 0) {
      $out_of_stock = '<span class="markProductOutOfStock">' . STOCK_MARK_PRODUCT_OUT_OF_STOCK . '</span>';
    }
    return $out_of_stock;
  }
////
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.