Jump to content
YePix

quantity monitoring

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.

Share this post


Link to post
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.

Share this post


Link to post
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'));
}
    }
  }
}

 

Share this post


Link to post
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?

 

Share this post


Link to post
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;
}

 

Share this post


Link to post
Share on other sites

This package can be closed.

Everything works best so far. I thank you for the obviously numerous support.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×