Stock level on catalog page

Posts: 25
Joined: 12/07/2007

Can I show the stock level on a catalog page. So that users know that a product is sold out or how many are in stock!

Thx

Posts: 78
Joined: 01/17/2008

I'm also interested in customizing the catalog page ... It would be nice if you had an option to show stock levels and a fast add to cart button or link. Less clicks for the users viewing the store.

Good with CSS - Bad with Code. Smiling

Posts: 25
Joined: 12/07/2007

To show the "add to cart" button that's possible. I don't know where to set this option at this moment, but I thought you can do it by shop configuration and then catalog.

But there you can't set the option to show the stock level on the catalog page.

Posts: 56
Joined: 10/07/2007

Have you guys checked out Inventory API & Simple Stock levels?:
http://www.ubercart.org/contrib/132

it is really sweet. If you can print out the levels of stock on admin, then yes, you will be able to do it front-end.

U just need to add the "stocklevels" from /admin/content/types/product/fields
to show on your product pages.... (haven't tried, but sure it would be easy)..

Would be a nice addition.. Will post if I have success..

Posts: 12
Joined: 03/02/2008

I'm currently working on code that provides Views integration for Ubercart Attributes:

http://www.ubercart.org/contrib/3960

The code includes some Stock integration (i.e. you can choose to display only those products that are in stock). Including a stock level field as part of that code wouldn't be difficult. This would provide you the ability to make a view that showed the stock level of a product with a specific set of attribute options. The specific set of options could be chosen by an option select box in the Views edit page, and the default would be to show the stock level for a product with no attributes or attribute options.

Admittedly, this doesn't get the Stock level built into Ubercart's catalog feature, but if you're comfortable using Views, this should do exactly what you want.

I suspect I won't be able to work on this feature until sometime next week, but let me know if this is what you're looking for and I'll make sure to put it on my To-Do list.

Posts: 171
Joined: 08/13/2007
Cool profile pic award.Getting busy with the Ubercode.Internationalizationizer

Maybe this is usefull to somebody:

It displays a small table with the current stocklevel of all stock-enabled SKU's for a product.

<?php
if ($node->type == 'product') {
 
$arr_sku = uc_stock_skus($node->nid);
 
$stock_html .='<table>';
  foreach(
$arr_sku as $sku){
   
$stocklevel = uc_stock_level($sku);
    if (
$stocklevel) {
      if (
$stocklevel < 1) {
       
$stocklevel = '<span class="nostock">'.$stocklevel.'</span>';
      }
     
$stock_html .='<tr><td>'.$sku.'</td><td>:&nbsp;&nbsp;'.$stocklevel.'</td></tr>';
    }
  }
 
$stock_html .='</table>';
}
?>

Put it in the node.tpl.php, and print the var $stock_html in a proper place.

Feel free to ask.

Regards,

Kees

Qrios Drupal Development

Posts: 6
Joined: 04/09/2008

How do i make stock level by stores?. How do i make store level inventory for each product?

How do i show which store the product is available?

How do i show which store is nearer to a zip code (different ranges).

Posts: 56
Joined: 10/07/2007

Sweet keesje76,
is that using the simple stock levels?
if so, I am gonna add it. means I can then add a nice icon as well.

Cheers for the share mate!

Posts: 40
Joined: 01/20/2008
Bug Finder

I'm finding this theme snippet to be a real gem as it dramatically cuts down customer questions about particular product attributes being in stock.

Placing the < ? php print $stock_html ? > in < fieldset class=" collapsible collapsed" > < / fieldset > tags, allows the table to be displayed in a collapsed field, which reduces screen clutter.

Two Questions:
1) Is there a way to use the snippet to display a message if there are no attributes in stock? (At the moment if no attributes are in stock, no table is rendered, which is confusing to the end user).

2) Also, this snippet only displays a decrease in stock when an item has been purchased. Is there any way to make it display a decrease when a product has been added to a cart, but hasn't yet been purchased.

^_^

Posts: 171
Joined: 08/13/2007
Cool profile pic award.Getting busy with the Ubercode.Internationalizationizer

pokerking400 wrote:
How do i make stock level by stores?. How do i make store level inventory for each product?

How do i show which store the product is available?

How do i show which store is nearer to a zip code (different ranges).

Sorry, I don't know what youre talkin about. Ubercart IS a store. Just one.
Set up Ubercart twice and (you wont believe)you will end up with two stores, each one with it's own stock! Wow!

Posts: 171
Joined: 08/13/2007
Cool profile pic award.Getting busy with the Ubercode.Internationalizationizer

Good suggestion, thanks for sharing.
Answers:
1) Yes there is, funny, I made a small module for it. Gonna release it since it seem I'm not the only one needing this. Hang on, I'l post here when it's ready.

2) This is the nature of Ubercart stock levels. I personally like it the way it is.

is that using the simple stock levels?
No, it's based on the core stock module. Maybe it works with simple stock too, don't know.

Posts: 1
Joined: 08/22/2008

Heyas

Any update on this ?

I sell a mixture of items that are "in stock" or "custom made" or "special ordered"

Being able to show current Stock Level on product page helps provide a "Lead Time" for my customer base

I am not good with coding so anything "point and shoot" is ideal for me Smiling

Posts: 31
Joined: 07/23/2008

Here's a simple way to display stock level for nodes, and also to remove the "add to cart" button if the stock is zero.

Add the following to the template.php file in your sites/all/themes/YOUR_THEME_NAME directory, changing the function name according to your theme's name:

function YOUR_THEME_NAME_uc_product_add_to_cart( $node ) {
  $stocklevel = uc_stock_level($node->model);
  if (is_numeric($stocklevel)) {
    // Stock tracking is active
    if ($stocklevel == 0) {
      return( '<div class="out_of_stock">' . t('Sorry, this item is out of stock') . '</div>' );
    } else {
      return( '<div class="stock_level">' . t('Number available: ') . $stocklevel . '</div>' ) . theme_uc_product_add_to_cart($node);
    }
  } else {
    // Stock tracking is not being used for this product, just show the add to cart button as normal
    return theme_uc_product_add_to_cart($node);
  }
}

Note that there are some obvious limitations to this:
1. It doesn't stop someone adding a quantity to their cart that is greater than the stock available
2. It doesn't update in real time so you may see the "add to cart" button but there may be no stock available by the time you click it
3. Stock is normally updated when an item is purchased, but this code tests at "add to cart" time
4. It is unlikely to work with product attributes. I don't use attributes, so didn't test it, but from what I understand about them, I think this approach is too simplistic.