There is a need for unique item selling : a better stock support with actions
if threshold is hit, maybe a trigger/predicate could hide product (unpublish it's node) so product won't be visible for visitors anymore

Thank you by avance, this lack of feature stoped me for weeks in drupal/ubercart progress

Comments

hedac’s picture

yes.. or change the add to cart button with a text explaining that there are no units left.

chourmovs’s picture

Thank you for your answer, but i take the risk that 2 customers buy the same product before i change the button, what is not acceptable for me

hedac’s picture

I mean it has to do it automatically. when stock is 0... remove the add to cart button automatically and put a "item sold" text instead.

chourmovs’s picture

Sorry
you're right, it can be a nice way to do this

dgitman’s picture

I'd like a "Sold" picture overlay and/or an item title change.

Passionate_Lass’s picture

I have been hunting for a similar function that disables buying when stock is empty.

I have found a lot of 5.x solutions but none for 6.x. I did find this thread - http://drupal.org/node/335010 but when I checked on the module it was only for 5.x. If I was a stronger coder I would probably just port the thing myself, unfortunately I'm not a strong coder and don't trust my abilities to create modules.

Maybe someone could take said existing module and port it.

Also, would a potential solution be to theme a product page and where the cart button is to throw in an if else statement?
If stock = 0
( change button to "Out of stock" and do not link to add to cart)
Else
(usual cart button and add to cart)

o.o

rszrama’s picture

Assigned: chourmovs » Unassigned
Status: Active » Closed (won't fix)

This ultimately needs to happen in contrib space w/ other stock related modules. At the very least, an issue should only be opened with a proposal and some patch development. : )

autopoietic’s picture

I have also been searching for an out of stock solution for ubercart 2.0. I found this module, which I intend to try:

http://drupal.org/project/uc_out_of_stock

joachim’s picture

Status: Closed (won't fix) » Active

I think at least some basic stock support needs to be in UC core.
I've had a look at the various stock control / stock display modules, and they are forced into some truly hacky solutions in order to implement what's a basic requirement:
- if product is not available for sale, don't show the add to cart button.

Currently, site developers either have to hack about in the theme layer, or do some wacky stuff like uc_out_of_stock using ajax (!!!!) to replace the add to cart button. This suggests that core needs to do something.

What I would suggest is a switch uc_product_for_sale() in core, alongside uc_product_is_product(). This would control whether any purchasing UI is shown.
By default this would always return TRUE -- let contrib modules supply information to this switch.
It would also be up to contrib modules to alter price display -- I can't find docs on the hook_uc_price_handler formatter callbacks, but I assume one could change the price entirely to say "out of stock" or "more expected in X days".

This would allow contrib to cover the many use cases:
- products merely out of stock -- show price but prevent buying
- products discontinued but shown for archive reasons -- probably want a flag for this; prevent buying AND don't show price.

fenstrat’s picture

+1 to joachim's idea. uc core needs to have beter support for stock control. The idea of a uc_product_for_sale() controlling if the add to cart is shown seems relatively straight forward.

The multi stock module has an interesting method for preventing buying out of stock items (as well as supporting stock levels for attributes).

Passionate_Lass’s picture

A good module that blocks users from purchasing out of stock products.

Ubercart Out of stock Notification
http://drupal.org/project/uc_out_of_stock

It works really well and I recommend it!

brisath’s picture

Subscribing

ikeigenwijs’s picture

It prevents the buying of the object
But it does not change the button,with the custom text.

TR’s picture

Version: 6.x-2.0-beta4 » 7.x-3.x-dev

Fixing all the problems with uc_stock will take some major API changes, so it's not something I'm prepared to do in Ubercart 2.x at this point.

I encourage you to start working with Drupal 7 / Ubercart 3.x to develop better stock handling for this next major revision of Ubercart. Now is the time to start proposing changes and working on new implementations to fix this.

TR’s picture

Title: Better stock support in Ubercart 2.x » Better stock support in Ubercart 3.x
TR’s picture

Issue tags: +uc_stock

I've gathered up all the open stock-related issues and tagged them with the uc_stock tag. Anyone working on improving stock in Ubercart should make sure to consider all those other issues when developing a solution.

jasonabc’s picture

subscribing

mo6’s picture

subscribe

spylvas’s picture

subscribe

TR’s picture

Consolidating issues: Marked #323703: Prevent selling of items with stock of zero as duplicate.

TR’s picture

Component: Code » Stock
Edy Gorbacev’s picture

this what i really want .. fyuh.. but then.. i want to put stock level in the front, i mean, to inform ppl for the left stock. how to do that?

keithm’s picture

+ on http://drupal.org/project/uc_multi_stock

Changing the button can be handled at the theme level. For example,

function site_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="add-to-cart out-of-stock">' . t('Out of stock') . '</div>';
    } 
    else {
      return 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);
  }
}

I have also implemented a decrement stock action when a user checks out with Paypal WPS. Works great.

armin1980’s picture

Assigned: Unassigned » armin1980
Priority: Normal » Critical

Hello

I have a problem and I want to see if someone can write a patch or module for me. I use Ubercart marketplace and items that are being sold on my web site are unique. When a seller lists a product on my web site, the default stock and threshold value is 0 (unlimited) and it should be manually overridden after listing a product. most of the times, sellers forget to do this simple thing and you know the rest better.
I want to define a default stock value for any product that is being listed on my web site. for example if seller X lists product X, the stock and threshold by default should be 1, not 0.

If you can help me out as soon as possible I'll be more than happy to donate money to ubercart project. just this simple thing has messed up all my operations and has made things very complicated. I use Drupal 6 and I can not upgrade to 7 right now because of lack of support from so many modules so I need it to be done with Ubercart 2.4 or anything compatible with drupal 6

thanks

podarok’s picture

subscribe

TR’s picture

Assigned: armin1980 » Unassigned
Priority: Critical » Normal
mirocow’s picture

subscribe

Anonymous’s picture

Subscribe. I'm using a customised version of http://drupal.org/project/uc_out_of_stock but there is no stable D7 release, and it's a messy way around the problem.
Good stock keeping is so essential to businesses that I am really surprised decent stock controls are not part of Ubercart's core.

TR’s picture

@TechNic: Is it important enough to you that you're willing to spend your own time and/or money developing it? Proper stock control can be done, but it really *doesn't* seem like the user community cares enough about it to expend the necessary effort or funds to do it properly. If you're making money by using this free software and you think it's lacking something, perhaps you can consider funding some specific improvements as a way of giving back to the community of volunteers who have made this all possible.

2faroffroad’s picture

@TechNic - Good stock keeping is so essential to businesses that I am really surprised decent stock controls are not part of Ubercart's core

I agree, there is no point for even having stock if it can not be controlled... Should rename the stock module to "Sale Counter". lol..
I too am working on something to block the "add to cart" button when a stock level hits 0... All we need is a rule for (when item is added to cart) or (when item is updated in cart) and it be able to check stock levels. But I am lost with this Rules thing for now... I will be reading more into it later.... Until then I continue to port the core hack I did in D6 U2.

Thanks.

Anonymous’s picture

@TR: I do get where you're coming from, but I'm afraid that my lack of money and coding skills mean that really the only option I personally have to contribute to the community is to try and feedback and engage in discussions with it. You have to give back the community in whatever way your means allow - but does lack of money mean you should have less of a voice?
Having said that, my organisation have recently paid a significant amount of money to a Drupal development company to help us implement Ubercart on our site. As part of this project, they contributed new modules and helped improve others. Sadly, the time we paid our developers for was not enough to solve the fundamental stock issues in Ubercart's core. Instead, like so many others, we have ended up with a system that required lots of custom coding and hacking about.

@2faroffroad: Thanks for the support. ;-)

TR’s picture

@TechNic: What I'm saying is that this is a well-known, long-standing problem, as evidenced by the above thread and other threads here in the issue queue and on ubercart.org. And it's going nowhere precisely because no-one seems to think it's important enough to spend their own time or money on, not because the maintainers are unaware of the problem or because we like it how it is. Of course your voice counts, but there's really nothing more to say on the stock issue that hasn't been said already - the only thing necessary right now is someone who can throw some resources at it.

*I* do not need the changes proposed here, so I feel no obligation to personally donate the many weeks of time it will take to properly re-architect stock handling and build the testing framework needed to ensure it works in a concurrent environment. And again, despite what all the "me too's" are saying, there's essentially no serious community interest. Compare stock to payment gateways - lots of people want support for their favorite payment gateway, so much so that there are hundreds of contributed payment gateways for Ubercart. This is clear evidence of a community that has spent time and money to make things happen that they really want. There is no such community effort with stock control. No contributed module correctly handles unique items in D6 or D7, which is the real test of the system. To do this properly requires transactions and architectural changes in Ubercart.

djh007’s picture

Since "out of stock" issues are not handled by the stock module, what's the best way to achieve this in D7 / UC3?

I'm trying to get this to work:

1) I found a great module that only allows a limited number of items to be added to cart: http://drupal.org/project/uc_product_minmax.
(This is great for unique items, since stock numbers are not changed until a sale is complete, so any stock-check code would be futile at the pre-checkout stage.)

2) I've also been trying to get this to work in my themes/template.php:

function dhcustom_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 else: ') . $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 ( '<div class="stock_level">' . t('Number : ') . $stocklevel . '</div>' ) . theme_uc_product_add_to_cart($node);
  }
}

I just get this error:

Notice: Trying to get property of non-object in dhcustom_uc_product_add_to_cart() (line 106 of C:\...\sites\all\themes\dhcustom\template.php).

Has anyone successfully had this working in D7 / UC3? Any ideas why it shouldn't?

I would be grateful for any clues as to how to implement this, or any other solution :)

djh007’s picture

Does anyone know if there is a solution for automated stock control (out of stock when stock level reaches 0), or am I wasting my time trying?

longwave’s picture

@djh007: Have you tried the uc_out_of_stock patch at #1201310: RFE: Update module to Drupal 7 and Ubercart 3.0?

conan_payne’s picture

It works if you replace the line: $stocklevel = uc_stock_level($node->model);
with: $stocklevel = uc_stock_level($node['form']['node']['#value']->model);

tkasis’s picture

I think this will be the correct thread to post this to. Kind of an old thread so probably everyone has already stumbled upon this.

Today I did this on my development site, http://cccoindevel.com/. This is Drupal 7 with Ubercart 3.

Problem: Since the majority of the client's products are one off collectors items they wanted the products to not be displayed when the stock level dropped to zero. This is the behavior on the existing osCommerce site, http://www.cccoinandcurrency.com/. I could do this with a view that filtered product nodes as published and stock level >= 1, but the client also wanted the product count shown per category (using Taxonomy Menu for this.) The Taxonomy Menu uses published nodes to create its values. I thought maybe seeing if there was a tweak to list only nodes in a view for the Taxonomy Menu count but that sounded like custom module time and more complexity than necessary. So I used the awesome Rules and Views Bulk Operations modules.

The client was not concerned about concurrent purchases of the same product. The rare instance of this can be handled administratively by giving a refund to one of the customers.

  • Ubercart Stock levels are not exposed to Rules so I created a content page view in Views to load lists into Rules. Really didn't need the page view as it won't be displayed but I might could use it as an administration tool later.
    • Filters
      • Content: Published (Yes)
      • Content: Type (= Product)
      • Stock: Level (< 1)
    • Fields
      • Content: Title << Not necessary but nice to see it work
      • Stock: Level (Stock Level) << Not necessary but nice to see it work
      • Bulk operations: Content (Content) << Though I did not need to choose any Operations, I did select "Unpublish content" in the config screen
  • I did use the page view to unpublish all the product nodes that were still published but had no stock (1264 of them) so I new the VBO worked
  • In Rules I created a component with the following actions
    • "Load a list of entity objects from a VBO View.", picked my new view and called it a 'product list'
    • Created a loop with the 'product list' nodes as the entities to process
    • Added an action to "Unpublish content" for each entity in the loop
    • Added an action to display a message that "Product [node:title] has been unpublished because the stock reached 0."
  • I tested the component manually a few times by manually decrementing stock on a few products and executing the component
  • I then added the component to a default Ubercart rule that decrements the stock on the event "Customer completes checkout".
  • Made a few test purchases until satisfied that it worked as intended
  • Deleted my display message action from the component.

I love Drupal. This could not have been done in WordPress or Joomla. Extensions of this power are just not available.

Thanks to Johan Falk (itangelo) for this series, http://nodeone.se/sv/node/32

Dalvtor’s picture

Hi tkasis. Thank you for your post, it was very useful.

I am stuck in this point: Added an action to "Unpublish content" for each entity in the loop

How do I do it? When i add a new action, unpublish content, then i can choose between: product-list:1 product-list:2, and so on.

Any help?

Thanks.

doppel’s picture

subscribing!

BigMike’s picture

Guys, this topic is from early 2009. There are many contrib modules available that satisfy the original poster's question, such as https://drupal.org/project/uc_out_of_stock, https://drupal.org/project/uc_multi_stock.

EDIT: Sorry just realized this is for UC 3.x. The UC Out of Stock module does have a Drupal 7.x version that has become available since this thread was created so check it-

BigMike

TR’s picture

Title: Better stock support in Ubercart 3.x » Better stock support
Version: 7.x-3.x-dev » 8.x-4.x-dev
Issue summary: View changes
Issue tags: -uc_stock

New features need to go into 8.x-4.x first at this point, then get backported as needed.