Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

quantity monitoring


YePix

Recommended Posts

vor 6 Stunden schrieb Jack_mcs:

The shopping cart page was just an example. The $cart variable is available throughout the shop, though you may need to use global $cart; in some places to make it usable. So anywhere you need to know the quantities in the shop, just use the code I posted and you will know. What you do with the results is up to you.

Will try to get it done somehow. I thank you sincerely for your help.

Link to comment
Share on other sites

vor 1 Stunde schrieb ArtcoInc:

@YePix Let me see if I understand your problem correctly ...

You say have enough meat to make 100 sandwiches, but only enough bread to make 10. This sounds like you need an add-on like Bundled Products

https://apps.oscommerce.com/BZ2FO&bundled-products

This way, your customers buy a sandwich, and the add-on automatically subtracts the inventory for both the meat and bread. When there is not enough bread to make any more sandwiches, the add-on states that there is not enough stock to assemble the requested sandwich.

This add-on will most likely need to be updated to work on a newer version of osC (either stock or community edition). Also, there is another add-on available specifically for the Phoenix/community edition version, but we can't discuss that here.

Excuse me if I misunderstood your problem ... 

Malcolm

Hi, that's exactly what I need. You got it right, thank you. I will take a look at this addon.

Link to comment
Share on other sites

Hi guys, I have one more request could someone help me capture products from a category?

This code only counts the inventory of a product.
But I need the quantity of all products from the same category that are in the shopping cart.
Got everything so far but I can't solve the last hurdle.

 

// Stock Categories Check
  if ( (STOCK_CHECK == 'true') && (STOCK_ALLOW_CHECKOUT != 'true') ) {
    $products = $cart->get_products();
    for ($i=0, $n=sizeof($products); $i<$n; $i++) {
if ((tep_not_null($products[$i]['stockname'])) && ($products[$i]['catstatus'] == 0)){
if ($products[$i]['quantity'] > $products[$i]['categoryqty']){
        tep_redirect(tep_href_link('shopping_cart.php'));
}
    }
  }
}

 

Link to comment
Share on other sites

OK. So far everything is going. But I have the problem that only registered customers can see the messages. as long as someone puts something in the shopping cart where the category amount exceeds, there will be no message. I have the category assignment for products in the shopping cart as follows:

general.php

////
function tep_count_products_qty_per_category($category_id) {
global $customer_id;
$products_query = tep_db_query("select * from " . TABLE_CUSTOMERS_BASKET . " cb, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where cb.products_id = p2c.products_id and p2c.categories_id = '" . (int)$category_id . "' and cb.customers_id = '" . (int)$customer_id . "'");
while($products = tep_db_fetch_array($products_query)) {
$qty += $products[customers_basket_quantity];
}
return $qty;
 }

#############################

shopping_cart.php

if (tep_count_products_qty_per_category($ctg_id, $cart->get_products()) > $products[$i]['categoryqty']){
$products_name .= ''
}

But now I stand on the hose as it should be done in order to make it visible to customers who are not logged in.

does anyone have an idea?

 

Link to comment
Share on other sites

Hi guys, I have one more question.

With the function everything works so far without any problems if a product is put directly from a category into the shopping cart.
If the product is linked in another category, the quantity category is no longer taken into account.
Here I have the problem with the parent_id Tried to solve it with the following code, but unfortunately can't get any further.

Does anyone have any idea what I'm doing wrong?

 

// Return the number quantity of products per category in a customers basket
// TABLES: customers_basket, products_to_categories
function tep_count_products_qty_per_category($category_id) {
global $customer_id;
$products_query = tep_db_query("select * from " . TABLE_CUSTOMERS_BASKET . " cb, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where cb.products_id = p2c.products_id and p2c.categories_id = '" . (int)$category_id . "' and cb.customers_id = '" . (int)$customer_id . "'");
$products = tep_db_fetch_array($products_query);
$qty += $products['customers_basket_quantity'];

$par_check_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . "  where parent_id = '" . (int)$category_id. "'");
if (tep_db_num_rows($par_check_query)) {
while ($par_check = tep_db_fetch_array($par_check_query)) {
$qty += tep_count_products_qty_per_category($par_check['categories_id']);
}
}
return $qty;
}

 

Link to comment
Share on other sites

  • 2 weeks later...

Hi folks, after there are so many who have viewed this post, I assume that it is of interest to many.

This code works with the main category and a sub-category.
I would ask the professionals here to take a look at it and maybe improve it accordingly so that it works for every category and sub-category.

This would certainly be of great benefit to many shop owners.

 

catalog/includes/classes/shopping_cart.php 

replace all of: 

        $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_baseprice, p.products_deposit, p.products_weight, p.products_status, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

to:

'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''));


with: 

        $products_query = tep_db_query("select p.products_id, 
                                              pd.products_name, 
                                               p.products_model, 
                                               p.products_image, 
                                               p.products_price, 
                                               p.products_weight, 
                                               p.products_tax_class_id, 
                                               c.categories_id,
                                               c.parent_id,
                                               c.categories_product_qty, 
                                               c.category_stock_status,
                                               cd.categories_name,
                                               cd.categories_stock 
                                          from " . TABLE_PRODUCTS . " p, 
                                               " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc,
                                               " . TABLE_PRODUCTS_DESCRIPTION . " pd, 
                                               " . TABLE_CATEGORIES . " c,
                                               " . TABLE_CATEGORIES_DESCRIPTION . " cd   
                                         where p.products_id = ptc.products_id and
                                               ptc.products_id = pd.products_id and 
                                               pd.products_id = '" . (int)$products_id . "' and
                                               ptc.categories_id = c.categories_id and 
                                               c.categories_id = cd.categories_id and 
                                               pd.language_id = '" . (int)$languages_id . "' and 
                                               cd.language_id = '" . (int)$languages_id . "'");
        if ($products = tep_db_fetch_array($products_query)) {
          $prid = $products['products_id'];

          $products_price = $products['products_price'];
          $candpid = $products['categories_id'];

          $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");
          if (tep_db_num_rows($specials_query)) {
            $specials = tep_db_fetch_array($specials_query);
            $products_price = $specials['specials_new_products_price'];
          }

          $pcsc_check_query = tep_db_query("select c.categories_id, c.parent_id, c.categories_product_qty, c.category_stock_status, c.category_stock_info_status, cd.categories_name, cd.categories_stock from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and parent_id = '" . (int)$candpid . "'");
          if (tep_db_num_rows($pcsc_check_query)) {
          $pcsc_check_row = tep_db_fetch_array($pcsc_check_query);
          $catpar_id = $pcsc_check_row['categories_id'];
          $par_id = $pcsc_check_row['parent_id'];
          $par_qty = $pcsc_check_row['categories_product_qty'];
          $par_stock_status = $pcsc_check_row['category_stock_status'];
          $par_stock_info_status = $pcsc_check_row['category_stock_info_status'];
          $par_cat_name = $pcsc_check_row['categories_name'];
          $par_stock = $pcsc_check_row['categories_stock'];
         }

          $products_array[] = array('id' => $products_id,
                                    'name' => $products['products_name'],
                                    'model' => $products['products_model'],
                                    'image' => $products['products_image'],
                                    'stl_title' => $products['products_stl_title'],
                                    'stl_id' => $products['products_stl_id'],
                                    'price' => $products_price,
                                    'quantity' => $this->contents[$products_id]['qty'],
                                    'weight' => $products['products_weight'],
                                    'final_price' => ($products_price + $this->attributes_price($products_id)),
                                    'tax_class_id' => $products['products_tax_class_id'],

                                    'catid' => $products['categories_id'],
                                    'catparid' => $catpar_id,
                                    'parid' => $par_id,
                                    'parqty' => $par_qty,
                                    'parststatus' => $par_stock_status,
                                    'parinfoststatus' => $par_stock_info_status,
                                    'parcatname' => $par_cat_name,
                                    'parstock' => $par_stock,

                                    'catname' => $products['categories_name'],
                                    'catqty' => $this->contents[$products_id]['categories_product_qty'],
                                    'categoryqty' => $products['categories_product_qty'],
                                    'catstatus' => $products['category_stock_status'],
                                    'stockname' => $products['categories_stock'],
                                    'stockalternat' => $products['categories_stock_alternatively'],
                                    'stockreplace' => $products['categories_stock_replacement'],

                                    'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''));

///////////////////////////
catalog/shopping_cart.php 

find:

$pID = current(explode("{", $products[$i]['id'])); 

add after:

// BOF categories stock info
// BOF Infoalert
$ctg_id = $products[$i]['catid'];
$catparid = $products[$i]['catparid'];
$candpid = $products[$i]['parid'];
$cat_iddif = tep_count_products_qty_per_category($ctg_id, $cart->get_products()) - $products[$i]['categoryqty'];
$ctg_iddif = tep_count_products_qty_per_category($ctg_id, $cart->get_products()) - $products[$i]['parqty'];
$candpid_dif = tep_count_products_qty_per_category($catparid, $cart->get_products()) - $products[$i]['parqty'];
$candpid_catid = tep_count_products_per_category($catparid, $cart->get_products());
$ctg_id_catid = tep_count_products_per_category($ctg_id, $cart->get_products());
// EOF Infoalert

// BOF parent_id status 0
if ($candpid === $ctg_id && $products[$i]['id'] === $candpid_catid){
if ((tep_not_null($products[$i]['parqty'])) && ($products[$i]['parststatus'] == 0)){
if (tep_count_products_qty_per_category($catparid, $cart->get_products()) > $products[$i]['parqty']){
if ($products[$i]['parqty'] == 0){
          $products_name .= '<div class="pls_PB5RED pls_BgrRed"><span class="catstock"><b><font color="#ff0000">' . TEXT_PRODUCT_INFO_TODAY_NOT_AVAILABLE . '</font></b></span></div>';
}else{
if ($products[$i]['parqty'] == 1){
          $products_name .= '<div class="pls_PB5RED pls_BgrRed"><span class="catstock"><b><font color="#0066ff">' . TEXT_INFO_ONE_CATEGORIES_STOCK . '&nbsp;' . $products[$i]['parqty'] . '&nbsp;' .  $products[$i]['parstock'] . '&nbsp;' . TEXT_INFO_SIX_CATEGORIES_STOCK . '&nbsp;"' . $products[$i]['catname'] . '"&nbsp;' . TEXT_INFO_THREE_CATEGORIES_STOCK . '</font><br><font color="#000000">' . TEXT_INFO_EIGHT_CATEGORIES_STOCK . '&nbsp;' . tep_count_products_qty_per_category($catparid, $cart->get_products()) . '&nbsp;' . $products[$i]['parstock'] . '&nbsp;' . TEXT_INFO_TEN_CATEGORIES_STOCK . '<br></font><font color="#FF0000">' . TEXT_INFO_THIRTEEN_CATEGORIES_STOCK  . '&nbsp;' .  $candpid_dif . '&nbsp;' . $products[$i]['parstock'] . '&nbsp;' . TEXT_INFO_FOURTEEN_CATEGORIES_STOCK . '</font></b><br></span></div>';
}else{
          $products_name .= '<div class="pls_PB5RED pls_BgrRed"><span class="catstock"><b><font color="#0066ff">' . TEXT_INFO_TWO_CATEGORIES_STOCK . '&nbsp;' . $products[$i]['parqty'] . '&nbsp;' .  $products[$i]['parstock'] . '&nbsp;' . TEXT_INFO_SIX_CATEGORIES_STOCK . '&nbsp;"' . $products[$i]['catname'] . '"&nbsp;' . TEXT_INFO_THREE_CATEGORIES_STOCK . '</font><br><font color="#000000">' . TEXT_INFO_EIGHT_CATEGORIES_STOCK . '&nbsp;' . tep_count_products_qty_per_category($catparid, $cart->get_products()) . '&nbsp;' . $products[$i]['parstock'] . '&nbsp;' . TEXT_INFO_TEN_CATEGORIES_STOCK . '<br></font><font color="#FF0000">' . TEXT_INFO_THIRTEEN_CATEGORIES_STOCK  . '&nbsp;' .  $candpid_dif . '&nbsp;' . $products[$i]['parstock'] . '&nbsp;' . TEXT_INFO_FOURTEEN_CATEGORIES_STOCK . '</font></b><br></span></div>';
}}
}}}
// EOF parent_id status 0
// BOF status 0
if ($products[$i]['id'] === $ctg_id_catid){
if ((tep_not_null($products[$i]['categoryqty'])) && ($products[$i]['catstatus'] == 0)){
if (tep_count_products_qty_per_category($ctg_id, $cart->get_products()) > $products[$i]['categoryqty']){
if ($products[$i]['categoryqty'] == 0){
          $products_name .= '<div class="pls_PB5RED pls_BgrRed"><span class="catstock"><b><font color="#ff0000">' . TEXT_PRODUCT_INFO_TODAY_NOT_AVAILABLE . '</font></b></span></div>';
}else{
if ($products[$i]['categoryqty'] == 1){
          $products_name .= '<div class="pls_PB5RED pls_BgrRed"><span class="catstock"><b><font color="#0066ff">' . TEXT_INFO_ONE_CATEGORIES_STOCK . '&nbsp;' . $products[$i]['categoryqty'] . '&nbsp;' .  $products[$i]['stockname'] . '&nbsp;' . TEXT_INFO_SIX_CATEGORIES_STOCK . '&nbsp;"' . $products[$i]['catname'] . '"&nbsp;' . TEXT_INFO_THREE_CATEGORIES_STOCK . '</font><br><font color="#000000">' . TEXT_INFO_EIGHT_CATEGORIES_STOCK . '&nbsp;' . tep_count_products_qty_per_category($ctg_id, $cart->get_products()) . '&nbsp;' . $products[$i]['stockname'] . '&nbsp;' . TEXT_INFO_TEN_CATEGORIES_STOCK . '<br></font><font color="#FF0000">' . TEXT_INFO_THIRTEEN_CATEGORIES_STOCK  . '&nbsp;' .  $cat_iddif . '&nbsp;' . $products[$i]['stockname'] . '&nbsp;' . TEXT_INFO_FOURTEEN_CATEGORIES_STOCK . '</font></b><br></span></div>';
}else{
          $products_name .= '<div class="pls_PB5RED pls_BgrRed"><span class="catstock"><b><font color="#0066ff">' . TEXT_INFO_TWO_CATEGORIES_STOCK . '&nbsp;' . $products[$i]['categoryqty'] . '&nbsp;' .  $products[$i]['stockname'] . '&nbsp;' . TEXT_INFO_SIX_CATEGORIES_STOCK . '&nbsp;"' . $products[$i]['catname'] . '"&nbsp;' . TEXT_INFO_THREE_CATEGORIES_STOCK . '</font><br><font color="#000000">' . TEXT_INFO_EIGHT_CATEGORIES_STOCK . '&nbsp;' . tep_count_products_qty_per_category($ctg_id, $cart->get_products()) . '&nbsp;' . $products[$i]['stockname'] . '&nbsp;' . TEXT_INFO_TEN_CATEGORIES_STOCK . '<br></font><font color="#FF0000">' . TEXT_INFO_THIRTEEN_CATEGORIES_STOCK  . '&nbsp;' .  $cat_iddif . '&nbsp;' . $products[$i]['stockname'] . '&nbsp;' . TEXT_INFO_FOURTEEN_CATEGORIES_STOCK . '</font></b><br></span></div>';
}}
}}}
// EOF status 0
// BOF parent_id status 1
if ($candpid === $ctg_id && $products[$i]['id'] === $candpid_catid){
if ((tep_not_null($products[$i]['parqty'])) && ($products[$i]['parststatus'] == 1)){
if (tep_count_products_qty_per_category($catparid, $cart->get_products()) > $products[$i]['parqty']){
if ($products[$i]['parqty'] == 0){
          $products_name .= '<div class="pls_PB5RED pls_BgrRed"><span class="catstock"><b><font color="#ff0000">' . TEXT_INFO_SEVEN_CATEGORIES_STOCK . '</font></b></span></div>';
}else{

if ($products[$i]['parqty'] == 1){
          $products_name .= '<div class="pls_PB5RED pls_BgrRed"><span class="catstock"><b><font color="#000000">' . TEXT_INFO_ONE_CATEGORIES_STOCK . '&nbsp;' . $products[$i]['parqty'] . '&nbsp;' .  $products[$i]['parstock'] . '&nbsp;' . TEXT_INFO_SIX_CATEGORIES_STOCK . '&nbsp;' . TEXT_INFO_THREE_CATEGORIES_STOCK . '</font><br><font color="#ff0000">' . TEXT_INFO_SEVEN_CATEGORIES_STOCK . '</font></b></span></div>';
}else{
          $products_name .= '<div class="pls_PB5RED pls_BgrRed"><span class="catstock"><b><font color="#000000">' . TEXT_INFO_TWO_CATEGORIES_STOCK . '&nbsp;' . $products[$i]['parqty'] . '&nbsp;' .  $products[$i]['parstock'] . '&nbsp;' . TEXT_INFO_SIX_CATEGORIES_STOCK . '&nbsp;' . TEXT_INFO_THREE_CATEGORIES_STOCK . '</font><br><font color="#ff0000">' . TEXT_INFO_SEVEN_CATEGORIES_STOCK . '</font></b></span></div>';
}}
}}}
// EOF parent_id status 1
// BOF status 1
if ($products[$i]['id'] === $ctg_id_catid){
if ((tep_not_null($products[$i]['categoryqty'])) && ($products[$i]['catstatus'] == 1)){
if (tep_count_products_qty_per_category($ctg_id, $cart->get_products()) > $products[$i]['categoryqty']){
if ($products[$i]['categoryqty'] == 0){
          $products_name .= '<div class="pls_PB5RED pls_BgrRed"><span class="catstock"><b><font color="#ff0000">' . TEXT_INFO_SEVEN_CATEGORIES_STOCK . '</font></b></span></div>';
}else{

if ($products[$i]['categoryqty'] == 1){
          $products_name .= '<div class="pls_PB5RED pls_BgrRed"><span class="catstock"><b><font color="#000000">' . TEXT_INFO_ONE_CATEGORIES_STOCK . '&nbsp;' . $products[$i]['categoryqty'] . '&nbsp;' .  $products[$i]['stockname'] . '&nbsp;' . TEXT_INFO_SIX_CATEGORIES_STOCK . '&nbsp;' . TEXT_INFO_THREE_CATEGORIES_STOCK . '</font><br><font color="#ff0000">' . TEXT_INFO_SEVEN_CATEGORIES_STOCK . '</font></b></span></div>';
}else{
          $products_name .= '<div class="pls_PB5RED pls_BgrRed"><span class="catstock"><b><font color="#000000">' . TEXT_INFO_TWO_CATEGORIES_STOCK . '&nbsp;' . $products[$i]['categoryqty'] . '&nbsp;' .  $products[$i]['stockname'] . '&nbsp;' . TEXT_INFO_SIX_CATEGORIES_STOCK . '&nbsp;' . TEXT_INFO_THREE_CATEGORIES_STOCK . '</font><br><font color="#ff0000">' . TEXT_INFO_SEVEN_CATEGORIES_STOCK . '</font></b></span></div>';
}}
}}}
// EOF status 1
// BOF parent_id status 2
if ($candpid === $ctg_id && $products[$i]['id'] === $candpid_catid){
if ((tep_not_null($products[$i]['parqty'])) && ($products[$i]['parststatus'] == 2)){
if (tep_count_products_qty_per_category($catparid, $cart->get_products()) > $products[$i]['parqty']){
if ($products[$i]['parqty'] == 0){
          $products_name .= '<div class="pls_PB5RED pls_BgrRed"><span class="catstock"><b><font color="#ff0000">' . $products[$i]['stockname'] . '&nbsp;' . TEXT_INFO_FOUR_CATEGORIES_STOCK . '</strong><br>' . TEXT_INFO_SEVEN_CATEGORIES_STOCK . '</font></b></span></div>';
}else{
if ($products[$i]['parqty'] == 1){
          $products_name .= '<div class="pls_PB5RED pls_BgrRed"><span class="catstock"><b><font color="#000000">' . TEXT_INFO_ONE_CATEGORIES_STOCK . '&nbsp;' . $products[$i]['categoryqty'] . '&nbsp;' .  $products[$i]['stockname'] . '&nbsp;' . TEXT_INFO_SIX_CATEGORIES_STOCK . '&nbsp;' . TEXT_INFO_THREE_CATEGORIES_STOCK . '</font><br><font color="#ff0000">' . TEXT_INFO_SEVEN_CATEGORIES_STOCK . '</font></b></span></div>';
}else{
          $products_name .= '<div class="pls_PB5RED pls_BgrRed"><span class="catstock"><b><font color="#000000">' . TEXT_INFO_TWO_CATEGORIES_STOCK . '&nbsp;' . $products[$i]['categoryqty'] . '&nbsp;' .  $products[$i]['stockname'] . '&nbsp;' . TEXT_INFO_SIX_CATEGORIES_STOCK . '&nbsp;' . TEXT_INFO_THREE_CATEGORIES_STOCK . '</font><br><font color="#ff0000">' . TEXT_INFO_SEVEN_CATEGORIES_STOCK . '</font></b></span></div>';
}}
}}}
// EOF parent_id status 2
// BOF status 2
if ($products[$i]['id'] === $ctg_id_catid){
if ((tep_not_null($products[$i]['categoryqty'])) && ($products[$i]['catstatus'] == 2)){
if (tep_count_products_qty_per_category($ctg_id, $cart->get_products()) > $products[$i]['categoryqty']){
if ($products[$i]['categoryqty'] == 0){
          $products_name .= '<div class="pls_PB5RED pls_BgrRed"><span class="catstock"><b><font color="#ff0000">' . $products[$i]['stockname'] . '&nbsp;' . TEXT_INFO_FOUR_CATEGORIES_STOCK . '</strong><br>' . TEXT_INFO_SEVEN_CATEGORIES_STOCK . '</font></b></span></div>';
}else{
if ($products[$i]['categoryqty'] == 1){
          $products_name .= '<div class="pls_PB5RED pls_BgrRed"><span class="catstock"><b><font color="#000000">' . TEXT_INFO_ONE_CATEGORIES_STOCK . '&nbsp;' . $products[$i]['categoryqty'] . '&nbsp;' .  $products[$i]['stockname'] . '&nbsp;' . TEXT_INFO_SIX_CATEGORIES_STOCK . '&nbsp;' . TEXT_INFO_THREE_CATEGORIES_STOCK . '</font><br><font color="#ff0000">' . TEXT_INFO_SEVEN_CATEGORIES_STOCK . '</font></b></span></div>';
}else{
          $products_name .= '<div class="pls_PB5RED pls_BgrRed"><span class="catstock"><b><font color="#000000">' . TEXT_INFO_TWO_CATEGORIES_STOCK . '&nbsp;' . $products[$i]['categoryqty'] . '&nbsp;' .  $products[$i]['stockname'] . '&nbsp;' . TEXT_INFO_SIX_CATEGORIES_STOCK . '&nbsp;' . TEXT_INFO_THREE_CATEGORIES_STOCK . '</font><br><font color="#ff0000">' . TEXT_INFO_SEVEN_CATEGORIES_STOCK . '</font></b></span></div>';
}}
}}}
// EOF status 2
// EOF categories stock info
//###########################

///////////////////////////
catalog/includes/fuctions/general.php 


function tep_count_products_per_category($category_id, $products_in_cart) {
for ($i=0, $n=sizeof($products_in_cart); $i<$n; $i++) {
$product = substr($products_in_cart[$i]['id'], '0', strcspn($products_in_cart[$i]['id'], '{'));
$products_list .= "(products_id = '" . $product . "') OR ";
}
$products_list =  '(' . substr_replace($products_list,"",-4) . ')';

$tcppc_query = tep_db_query("select products_id as prodid from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$category_id . "' and " . $products_list);
$tcppc = tep_db_fetch_array($tcppc_query);
$tcppc_count += $tcppc['prodid'];

return $p2c_count;
}
 
////
function tep_count_products_qty_per_category($category_id) {
global $customer_id;
$products_query = tep_db_query("select * from " . TABLE_CUSTOMERS_BASKET . " cb, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where cb.products_id = p2c.products_id and p2c.categories_id = '" . (int)$category_id . "' and cb.customers_id = '" . (int)$customer_id . "'");
while($products = tep_db_fetch_array($products_query)) {
$qty += $products['customers_basket_quantity'];
}
return $qty;
}

////
function tep_count_category_products_qty_per_category($category_id) {
$cat_products_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc where p.products_id = ptc.products_id and ptc.categories_id = '" . (int)$category_id . "' and p.products_status = 1");
while($cat_products = tep_db_fetch_array($cat_products_query)) {
$cat_qty = $cat_products['count'];
}
return $cat_qty;
}

///////////////////////////

catalog/checkout_payment.php & checkout_confirmation.php

// Stock Categories Check
if ( (STOCK_CHECK == 'true') && (STOCK_ALLOW_CHECKOUT != 'true') ) {
$products = $cart->get_products();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
$ctg_id = $products[$i]['catid'];
if ((tep_not_null($products[$i]['categoryqty'])) && ($products[$i]['catstatus'] == 0)){
if (tep_count_products_qty_per_category($ctg_id, $cart->get_products()) > $products[$i]['categoryqty']){
tep_redirect(tep_href_link('shopping_cart.php'));
}
    }
  }
}

// Stock Categories parent Check
if ( (STOCK_CHECK == 'true') && (STOCK_ALLOW_CHECKOUT != 'true') ) {
$products = $cart->get_products();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
$catparid = $products[$i]['catparid'];
if ((tep_not_null($products[$i]['parqty'])) && ($products[$i]['parststatus'] == 0)){
if (tep_count_products_qty_per_category($catparid, $cart->get_products()) > $products[$i]['parqty']){
tep_redirect(tep_href_link('shopping_cart.php'));
}
    }
  }
}

///////////////////////////

catalog/checkout_process.php

$stock_categories_query = tep_db_query("select p.products_id, c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc, " . TABLE_CATEGORIES . " c where p.products_id = ptc.products_id and ptc.products_id = '" . tep_get_prid($order->products[$i]['id']) . "' and ptc.categories_id = c.categories_id");
$st_cat_values = tep_db_fetch_array($stock_categories_query);
$ctg_id = $st_cat_values['categories_id'];
$pr_id = tep_get_prid($order->products[$i]['id']);
$pcsc_check_query = tep_db_query("select p.products_id, c.categories_id, c.parent_id, c.categories_product_qty, c.category_stock_status from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc, " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where p.products_id = ptc.products_id and ptc.categories_id = c.categories_id and c.categories_id = cd.categories_id and p.products_id = '" . $pr_id . "' and c.categories_id and c.parent_id = '" . $ctg_id . "'");
if (tep_db_num_rows($pcsc_check_query)) {
$pcsc_check_row = tep_db_fetch_array($pcsc_check_query);
$catpar_id = $pcsc_check_row['categories_id'];
$par_id = $pcsc_check_row['parent_id'];
$par_qty = $pcsc_check_row['categories_product_qty'];
$par_stock_status = $pcsc_check_row['category_stock_status'];
}
if (tep_not_null($par_qty && $par_id === $ctg_id)) {
tep_db_query("update " . TABLE_CATEGORIES . " set categories_product_qty = '" . (int)$par_qty . "' - " . sprintf('%d', $order->products[$i]['qty']) . " where categories_id = '" . (int)$catpar_id . "'");
$cat_stock = tep_db_query("select categories_id, categories_product_qty from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$catpar_id . "'");
$cs = tep_db_fetch_array($cat_stock);
if ($cs['categories_product_qty'] < 1) {
tep_db_query("update " . TABLE_CATEGORIES . " set categories_product_qty = NULL where categories_id = '" . (int)$cs['categories_id'] . "'");
tep_db_query("update " . TABLE_CATEGORIES_DESCRIPTION . " set categories_stock  = NULL where categories_id = '" . (int)$cs['categories_id'] . "'");
}
if (($par_stock_status == '0') || ($par_stock_status == '2')){
if ($cs['categories_product_qty'] < 1) {
tep_db_query("update " . TABLE_CATEGORIES . " set categories_status = '0' where categories_id = '" . (int)$cs['categories_id'] . "'");
$stprcat_query = tep_db_query("select p.products_id, ptc.products_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc,  " . TABLE_CATEGORIES . " c where p.products_id = ptc.products_id and ptc.categories_id = c.categories_id and c.categories_id = '" . (int)$cs['categories_id'] . "'");
while ($stprcat = tep_db_fetch_array($stprcat_query)){
tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . (int)$stprcat['products_id'] . "'");
}}}}

$pcsc_check_two_query = tep_db_query("select p.products_id, c.categories_id, c.parent_id, c.categories_product_qty, c.category_stock_status from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc, " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where p.products_id = ptc.products_id and ptc.categories_id = c.categories_id and c.categories_id = cd.categories_id and p.products_id = '" . $pr_id . "' and c.categories_id and c.parent_id = '0'");
if (tep_db_num_rows($pcsc_check_two_query)) {
$pcsc_check_two_row = tep_db_fetch_array($pcsc_check_two_query);
$catpar_two_id = $pcsc_check_two_row['categories_id'];
$par_two_id = $pcsc_check_two_row['parent_id'];
$par_two_qty = $pcsc_check_two_row['categories_product_qty'];
$par_two_stock_status = $pcsc_check_two_row['category_stock_status'];
}
if (tep_not_null($par_two_qty)) {
tep_db_query("update " . TABLE_CATEGORIES . " set categories_product_qty = '" . (int)$par_two_qty . "' - " . sprintf('%d', $order->products[$i]['qty']) . " where categories_id = '" . (int)$catpar_two_id . "'");
$cat_two_stock = tep_db_query("select categories_id, categories_product_qty from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$catpar_two_id . "'");
$cs_two = tep_db_fetch_array($cat_two_stock);
if ($cs_two['categories_product_qty'] < 1) {
tep_db_query("update " . TABLE_CATEGORIES . " set categories_product_qty = NULL where categories_id = '" . (int)$cs_two['categories_id'] . "'");
tep_db_query("update " . TABLE_CATEGORIES_DESCRIPTION . " set categories_stock  = NULL where categories_id = '" . (int)$cs_two['categories_id'] . "'");
}
if (($par_two_stock_status == '0') || ($par_two_stock_status == '2')){
if ($cs_two['categories_product_qty'] < 1) {
tep_db_query("update " . TABLE_CATEGORIES . " set categories_status = '0' where categories_id = '" . (int)$cs_two['categories_id'] . "'");
$stprcat_two_query = tep_db_query("select p.products_id, ptc.products_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc,  " . TABLE_CATEGORIES . " c where p.products_id = ptc.products_id and ptc.categories_id = c.categories_id and c.categories_id = '" . (int)$cs_two['categories_id'] . "'");
while ($stprcat_two = tep_db_fetch_array($stprcat_two_query)){
tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . (int)$stprcat_two['products_id'] . "'");
}}}}

///////////////////////////

catalog/admin/categories.php

find:
      case 'insert_category':
      case 'update_category':

add in this section:

        $categories_product_qty = tep_db_prepare_input($_POST['categories_product_qty']);
        $category_stock_status = tep_db_prepare_input($_POST['category_stock_status']);
        $category_stock_info_status = tep_db_prepare_input($_POST['category_stock_info_status']);
############

find:
        $sql_data_array = array('sort_order' => (int)$sort_order,

add in this section:
 
                                'categories_product_qty' => $categories_product_qty,
                                'category_stock_status' => $category_stock_status,
                                'category_stock_info_status' => $category_stock_info_status);
attention by " );"
############

find:
        if (USE_CACHE == 'true') {
          tep_reset_cache_block('categories');

add before:

        $cat_stock_att_image = new upload('cat_stock_att_image');
        $cat_stock_att_image->set_destination(DIR_FS_CATALOG_IMAGES);

        if ($cat_stock_att_image->parse() && $cat_stock_att_image->save()) {
          tep_db_query("update " . TABLE_CATEGORIES . " set cat_stock_att_image = '" . tep_db_input($cat_stock_att_image->filename) . "' where categories_id = '" . (int)$categories_id . "'");
        }

// ********************************** categories.php
// BOF update categories_product_qty
if ($categories_product_qty == 0) {
tep_db_query("update " . TABLE_CATEGORIES . " set categories_product_qty = NULL where categories_id = '" . (int)$categories_id . "'");
}
// EOF update categories_product_qty
// ********************************** categories.php

// ********************************** categories.php
// BOF update categories_stock
if (empty($sql_data_array['categories_stock'])) {
tep_db_query("update " . TABLE_CATEGORIES_DESCRIPTION . " set categories_stock = NULL where categories_id = '" . (int)$categories_id . "'");
}
// EOF update categories_stock
// ********************************** categories.php

// ********************************** categories.php
// BOF update categories_stock_alternatively
if (empty($sql_data_array['categories_stock_alternatively'])) {
tep_db_query("update " . TABLE_CATEGORIES_DESCRIPTION . " set categories_stock_alternatively = NULL where categories_id = '" . (int)$categories_id . "'");
}
// EOF update categories_stock_alternatively
// ********************************** categories.php

// ********************************** categories.php
// BOF update categories_stock_replacement
if (empty($sql_data_array['categories_stock_replacement'])) {
tep_db_query("update " . TABLE_CATEGORIES_DESCRIPTION . " set categories_stock_replacement = NULL where categories_id = '" . (int)$categories_id . "'");
}
// EOF update categories_stock_replacement
// ********************************** categories.php
############

find:

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, cd.categories_description,

add to:

, cd.categories_stock, cd.categories_stock_alternatively, cd.categories_stock_replacement, c.categories_product_qty, c.category_stock_status, c.cat_stock_att_image, c.category_stock_info_status

############

find:
    switch ($action) {
      case 'new_category':

add before:

// PLS CATEGORY STOCK INFO STATUS
    if (isset($cInfo->category_stock_info_status)) {
      $cstock_info_on = ($cInfo->category_stock_info_status == '1') ? true : false;
    } else {
      $cstock_info_on = ($cInfo->category_stock_info_status == '1') ? true : false;
    }
    $cstock_info_off = !$cstock_info_on;

if ($cInfo->category_stock_info_status == '0') {
   $stock_info_status = TEXT_EDIT_CATEGORIES_STOCK_INFO_STATUS_OFF;
   }
if ($cInfo->category_stock_info_status == '1') {
   $stock_info_status = TEXT_EDIT_CATEGORIES_STOCK_INFO_STATUS_ON;
}

// PLS CATEGORY STOCK STATUS
    if (!isset($pInfo->category_stock_status)) $pInfo->category_stock_status = '1';
    switch ($cInfo->category_stock_status) {
      case '0': $cstock_on = false; $cstock_att = false; $cstock_off = true; break;
      case '1': $cstock_on = true; $cstock_att = false; $cstock_off = false; break;
      case '2': $cstock_on = false; $cstock_att = true; $cstock_off = false; break;
      default: $cstock_on = false; $cstock_att = false; $cstock_off = true;
    }

############

find in case 'new_category':

        $category_inputs_string = 

add in this section:

$categories_stock_title_string = $categories_stock_alternatively_title_string = $categories_stock_replacement_title_string

############

find in  case 'new_category':

        $languages = tep_get_languages();
        for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {

add in this section:

          $categories_stock_title_string .= '<br />' . tep_image(tep_catalog_href_link('includes/languages/' . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], '', 'SSL'), $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('categories_stock[' . $languages[$i]['id'] . ']');
          $categories_stock_alternatively_title_string .= '<br />' . tep_image(tep_catalog_href_link('includes/languages/' . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], '', 'SSL'), $languages[$i]['name'], '', '', 'style="vertical-align: top;"') . '&nbsp;' . tep_draw_textarea_field('categories_stock_alternatively[' . $languages[$i]['id'] . ']', 'soft', '40', '5');
          $categories_stock_replacement_title_string .= '<br />' . tep_image(tep_catalog_href_link('includes/languages/' . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], '', 'SSL'), $languages[$i]['name'], '', '', 'style="vertical-align: top;"') . '&nbsp;' . tep_draw_textarea_field('categories_stock_replacement[' . $languages[$i]['id'] . ']', 'soft', '40', '5');

############

find in case 'edit_category':

        $languages = tep_get_languages();
        for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {

add in this section:

          $categories_stock_title_string .= '<br />' . tep_image(tep_catalog_href_link('includes/languages/' . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], '', 'SSL'), $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('categories_stock[' . $languages[$i]['id'] . ']', tep_get_categories_stock_qty($cInfo->categories_id, $languages[$i]['id']));
          $categories_stock_alternatively_title_string .= '<br />' . tep_image(tep_catalog_href_link('includes/languages/' . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], '', 'SSL'), $languages[$i]['name'], '', '', 'style="vertical-align: top;"') . '&nbsp;' . tep_draw_textarea_field('categories_stock_alternatively[' . $languages[$i]['id'] . ']', 'soft', '40', '5', tep_get_categories_alternatively_stock($cInfo->categories_id, $languages[$i]['id']));
          $categories_stock_replacement_title_string .= '<br />' . tep_image(tep_catalog_href_link('includes/languages/' . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], '', 'SSL'), $languages[$i]['name'], '', '', 'style="vertical-align: top;"') . '&nbsp;' . tep_draw_textarea_field('categories_stock_replacement[' . $languages[$i]['id'] . ']', 'soft', '40', '5', tep_get_categories_replacement_stock($cInfo->categories_id, $languages[$i]['id']));

############

find:
    switch ($action) {
      case 'new_category':

add in this section:

        $contents[] = array('text' => '<hr>' . TEXT_EDIT_CATEGORY_STOCK . '<br />' . tep_draw_input_field('categories_product_qty', $cInfo->categories_product_qty, 'size="2"') . '<hr>' . TEXT_EDIT_CATEGORIES_STOCK_TITLE . $categories_stock_title_string . '<hr>' . TEXT_EDIT_CATEGORIES_STOCK_INFO_STATUS . '<br />' . tep_draw_radio_field('category_stock_info_status', '1', $cstock_info_on) . '&nbsp;&nbsp;' . TEXT_EDIT_CATEGORIES_STOCK_INFO_STATUS_ON . '&nbsp;&nbsp;' . tep_draw_radio_field('category_stock_info_status', '0', $cstock_info_off) . '&nbsp;&nbsp;' . TEXT_EDIT_CATEGORIES_STOCK_INFO_STATUS_OFF . '<hr>' . TEXT_EDIT_CATEGORIES_STOCK_STATUS . '<br />' . tep_draw_radio_field('category_stock_status', '0', $cstock_off) . '&nbsp;&nbsp;' . TEXT_EDIT_CATEGORIES_STOCK_STATUS_OFF . '<br>' . tep_draw_radio_field('category_stock_status', '1', $cstock_on) . '&nbsp;&nbsp;' . TEXT_EDIT_CATEGORIES_STOCK_STATUS_ON . '<br>' . tep_draw_radio_field('category_stock_status', '2', $cstock_att) . '&nbsp;&nbsp;' . TEXT_EDIT_CATEGORIES_STOCK_STATUS_ATT . '<hr>' . TEXT_CATEGORIES_STOCK_ALTERNATIVELY_TITLE . $categories_stock_alternatively_title_string . '<hr>' . TEXT_CATEGORIES_STOCK_REPLACEMENT_TITLE . $categories_stock_replacement_title_string . '<hr>' . TEXT_CATEGORIES_ATT_IMAGE . '<br />' . $cInfo->cat_stock_att_image . '</strong>' . tep_draw_file_field('cat_stock_att_image') . '<hr>');

############

find:
      case 'edit_category':

add in this section:

        $contents[] = array('text' => '<hr>' . TEXT_EDIT_CATEGORY_STOCK . '<br />' . tep_draw_input_field('categories_product_qty', $cInfo->categories_product_qty, 'size="2"') . '<hr>' . TEXT_EDIT_CATEGORIES_STOCK_TITLE . $categories_stock_title_string . '<hr>' . TEXT_EDIT_CATEGORIES_STOCK_INFO_STATUS . '<br />' . tep_draw_radio_field('category_stock_info_status', '1', $cstock_info_on) . '&nbsp;&nbsp;' . TEXT_EDIT_CATEGORIES_STOCK_INFO_STATUS_ON . '&nbsp;&nbsp;' . tep_draw_radio_field('category_stock_info_status', '0', $cstock_info_off) . '&nbsp;&nbsp;' . TEXT_EDIT_CATEGORIES_STOCK_INFO_STATUS_OFF . '<hr>' . TEXT_EDIT_CATEGORIES_STOCK_STATUS . '<br />' . tep_draw_radio_field('category_stock_status', '0', $cstock_off) . '&nbsp;&nbsp;' . TEXT_EDIT_CATEGORIES_STOCK_STATUS_OFF . '<br>' . tep_draw_radio_field('category_stock_status', '1', $cstock_on) . '&nbsp;&nbsp;' . TEXT_EDIT_CATEGORIES_STOCK_STATUS_ON . '<br>' . tep_draw_radio_field('category_stock_status', '2', $cstock_att) . '&nbsp;&nbsp;' . TEXT_EDIT_CATEGORIES_STOCK_STATUS_ATT . '<hr>' . TEXT_CATEGORIES_STOCK_ALTERNATIVELY_TITLE . $categories_stock_alternatively_title_string . '<hr>' . TEXT_CATEGORIES_STOCK_REPLACEMENT_TITLE . $categories_stock_replacement_title_string . '<hr>' . TEXT_CATEGORIES_ATT_IMAGE . '<br />' . tep_image(HTTP_CATALOG_SERVER . DIR_WS_CATALOG_IMAGES . $cInfo->cat_stock_att_image, $cInfo->categories_name, CATEGORIES_ATT_IMAGE_WIDTH, CATEGORIES_ATT_IMAGE_HEIGHT) . '<br />' . DIR_WS_CATALOG_IMAGES . '<br /><strong>' . $cInfo->cat_stock_att_image . '</strong>' . tep_draw_file_field('cat_stock_att_image') . '<hr>');

############

///////////////////////////
catalog/admin/includes/functions/general.php

  function tep_get_categories_stock_qty($category_id, $language_id = 0) {
    global $languages_id;

add to the end:

    if ($language_id == 0) $language_id = $languages_id;
    $category_query = tep_db_query("select categories_stock from categories_description where categories_id = '" . (int)$category_id . "' and language_id = '" . (int)$language_id . "'");
    $category = tep_db_fetch_array($category_query);

    return $category['categories_stock'];
  }

  function tep_get_categories_alternatively_stock($category_id, $language_id = 0) {
    global $languages_id;

    if ($language_id == 0) $language_id = $languages_id;
    $category_query = tep_db_query("select categories_stock_alternatively from categories_description where categories_id = '" . (int)$category_id . "' and language_id = '" . (int)$language_id . "'");
    $category = tep_db_fetch_array($category_query);

    return $category['categories_stock_alternatively'];
  }


  function tep_get_categories_replacement_stock($category_id, $language_id = 0) {
    global $languages_id;

    if ($language_id == 0) $language_id = $languages_id;
    $category_query = tep_db_query("select categories_stock_replacement from categories_description where categories_id = '" . (int)$category_id . "' and language_id = '" . (int)$language_id . "'");
    $category = tep_db_fetch_array($category_query);

    return $category['categories_stock_replacement'];
  }

///////////////////////////

catalog/includes/languages/german.php

add:

define('TEXT_INFO_ONE_CATEGORIES_STOCK', 'Für heute ist noch'); 
define('TEXT_INFO_TWO_CATEGORIES_STOCK', 'Für heute sind noch'); 
define('TEXT_INFO_THREE_CATEGORIES_STOCK', 'verfügbar.'); 
define('TEXT_INFO_FOUR_CATEGORIES_STOCK', 'Für heute bereits ausverkauft.'); 
define('TEXT_INFO_FIVE_CATEGORIES_STOCK', 'Bitte Mengen beachten.'); 
define('TEXT_INFO_SIX_CATEGORIES_STOCK', 'in der Kategorie'); 
define('TEXT_INFO_SEVEN_CATEGORIES_STOCK', '[BITTE UNTEN HINWEIS BEACHTEN]'); 
define('TEXT_INFO_ATT_STOCK_IMAGE', 'Bild hier ansehen'); 
define('TEXT_INFO_EIGHT_CATEGORIES_STOCK', 'Sie haben jetzt schon'); 
define('TEXT_INFO_NINE_CATEGORIES_STOCK', 'von'); 
define('TEXT_INFO_TEN_CATEGORIES_STOCK', 'im Warenkorb.'); 
define('TEXT_INFO_ELEVEN_CATEGORIES_STOCK', 'Stück'); 
define('TEXT_INFO_TWELVE_CATEGORIES_STOCK', 'BITTE REDUZIEREN.'); 
define('TEXT_INFO_THIRTEEN_CATEGORIES_STOCK', 'Bitte die Menge um'); 
define('TEXT_INFO_FOURTEEN_CATEGORIES_STOCK', 'reduzieren.'); 
define('TEXT_INFO_FIFTEEN_CATEGORIES_STOCK', 'beliebiges'); 
define('TEXT_INFO_SIXTEEN_CATEGORIES_STOCK', 'beliebige'); 

///////////////////////////

catalog/admin/includes/languages/german/categories.php

add:

define('TEXT_EDIT_CATEGORY_STOCK', '<b>Kategorie-Lagermenge.</b><br>Geben Sie den Bestand an, der in dieser Kategorie verfügbar ist. Danach wird diese inklusive aller Produkte deaktiviert.<br>Ansonsten bitte feld leer lassen.');
define('TEXT_EDIT_CATEGORIES_STOCK_TITLE', '<b>Bezeichnung-Lagermenge.</b><br>Geben Sie die Bezeichnung der Produkte an, der in dieser Kategorie verfügbar ist. Z. B. Kartons, Sandwichbrötchen, ...<br>Ansonsten bitte feld leer lassen.');
define('TEXT_EDIT_CATEGORIES_STOCK_STATUS', 'Kategorie und alle Produkte in dieser Kategorie Bei Lagermenge 0 <b>Abschalten</b> oder Info für Alternative oder Ersatzprodukte einblenden.');
define('TEXT_EDIT_CATEGORIES_STOCK_STATUS_ON', '<b>Alternativprodukt</b>');
define('TEXT_EDIT_CATEGORIES_STOCK_STATUS_OFF', '<b>Abschalten</b>');
define('TEXT_CATEGORIES_STOCK_ALTERNATIVELY_TITLE', '<b>Infotext für Alternativprodukt.</b><br>Kategorie und Produkte werden nicht deaktiviert. Alternativprodukte werden angeboten.');
define('TEXT_EDIT_CATEGORIES_STOCK_STATUS_ATT', '<b>Ersatzprodukt und abschalten</b>');
define('TEXT_CATEGORIES_STOCK_REPLACEMENT_TITLE', '<b>Infotext für Ersatzprodukt.</b><br>Kategorie und Produkte werden bei bestand 0 deaktiviert. Bei bestellung von mehr Produkten als Lagerbestand wird einmalig Alternativprodukt angeboten');
define('TEXT_CATEGORIES_ATT_IMAGE', '<b>Bild für Alternativprodukt</b>');
define('CATEGORIES_STOCK_STATUS', '<b>Bei Menge 0:</b>');
define('CATEGORIES_STOCK_INFO', '<b>Produkt-Infostatus:</b>');
define('TEXT_EDIT_CATEGORIES_STOCK_INFO_STATUS', '<b>Infos und Zusatztexte anzeigen ?</b><br>Dazu gehören Seiten wie: Produkt-Infoseite, Warenkorb und die Startseite bei den Kategorien.');
define('TEXT_EDIT_CATEGORIES_STOCK_INFO_STATUS_ON', '<b>Anzeigen</b>');
define('TEXT_EDIT_CATEGORIES_STOCK_INFO_STATUS_OFF', '<b>Ausblenden</b>');
define('TEXT_PRODUCTS_STOCKLABEL', 'Zuordnungsoption:');
define('TEXT_PRODUCTS_STOCKLABEL_TITLE', 'Lagerposition:');
define('TEXT_PRODUCTS_STOCKLABEL_ID', 'Lager-ID:');
define('TEXT_PRODUCTS_STOCKLABEL_BUTTON', 'Lager ansehen');

///////////////////////////

SQL in phpMyAdmin

add to TB - categories

categories_product_qty	int(3)	NULL
category_stock_status	int(1)
cat_stock_att_image	varchar(64)	utf8_general_ci NULL
category_stock_info_status	int(1)


add to TB - categories_description

categories_stock  text  utf8_general_ci  NULL
categories_stock_alternatively  text  utf8_general_ci  NULL
categories_stock_replacement  text  utf8_general_ci  NULL

############

 

Link to comment
Share on other sites

admin/categories.php

find:

            <td class="pageHeading"><?php echo sprintf(TEXT_NEW_PRODUCT, tep_output_generated_category_path($current_category_id)); ?></td>

and change to:

            <td class="pageHeading"><?php if (tep_not_null($pInfo->products_id, $languages[$i]['id'])){echo tep_get_products_name($pInfo->products_id, $languages[$i]['id']);}else{echo sprintf(TEXT_NEW_PRODUCT, tep_output_generated_category_path($current_category_id));} ?></td>

 

Link to comment
Share on other sites

One last try to get some help. I have new roles here. Everything works perfectly but only when the customer is logged in.

 

// BOF stl stock check *******
function tep_get_products_stl_stock($products_id) {
$products_id = tep_get_prid($products_id);
$stock_query = tep_db_query("select products_stl_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
$stock_values = tep_db_fetch_array($stock_query);
$slabel_product_query = tep_db_query("select stocklabel_stock from " . TABLE_PRODUCTS . " p, " . TABLE_STOCKLABEL . " sl where p.products_stl_id = '" . $stock_values['products_stl_id'] . "' and p.products_stl_id = sl.stocklabel_id");
$slabel_product = tep_db_fetch_array($slabel_product_query);
return $slabel_product['stocklabel_stock'];
}

function tep_count_products_stl_stock_per_stl_id($products_id) {
global $customer_id;
$products_id = tep_get_prid($products_id);
$stock_query = tep_db_query("select products_stl_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
$stock_values = tep_db_fetch_array($stock_query);
$products_query = tep_db_query("select * from " . TABLE_CUSTOMERS_BASKET . " cb, " . TABLE_PRODUCTS . " p, " . TABLE_STOCKLABEL . " sl where cb.products_id = p.products_id and p.products_stl_id = '" . (int)$stock_values['products_stl_id'] . "' and p.products_stl_id = sl.stocklabel_id and cb.customers_id = '" . (int)$customer_id . "' and sl.stocklabel_status = '1'");
while($products = tep_db_fetch_array($products_query)) {
$qty += $products['customers_basket_quantity'];
}
return $qty;
}

function tep_check_stl_stock($products_id) {
$stock_stl_left = tep_get_products_stl_stock($products_id) - tep_count_products_stl_stock_per_stl_id($products_id);
$out_of_stl_stock = '';
if ($stock_stl_left < 0) {
$out_of_stl_stock = '<span class="text-danger"><b>' . STOCK_MARK_PRODUCT_OUT_OF_STL_STOCK . '&nbsp;' . OUT_OF_STL_STOCK_INFO_CHECKOUT . '</b></span>';
}
return $out_of_stl_stock;
}
// EOF stl stock check *******

 

Can someone help me to change the following function so that visitors who are not logged in receive the message that there are too many items in the shopping cart than available. ?

 

function tep_count_products_stl_stock_per_stl_id($products_id) {
global $customer_id;
$products_id = tep_get_prid($products_id);
$stock_query = tep_db_query("select products_stl_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
$stock_values = tep_db_fetch_array($stock_query);
$products_query = tep_db_query("select * from " . TABLE_CUSTOMERS_BASKET . " cb, " . TABLE_PRODUCTS . " p, " . TABLE_STOCKLABEL . " sl where cb.products_id = p.products_id and p.products_stl_id = '" . (int)$stock_values['products_stl_id'] . "' and p.products_stl_id = sl.stocklabel_id and cb.customers_id = '" . (int)$customer_id . "' and sl.stocklabel_status = '1'");
while($products = tep_db_fetch_array($products_query)) {
$qty += $products['customers_basket_quantity'];
}
return $qty;
}

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...