I thought the stock module included with ubercart 2.x would allow this, but customers can still order "out of stock" items". Am I missing something?
Look at this thread, and read comment #13 by me (keyone)
http://www.ubercart.org/forum/support/4037/stock_level_product_page
I use content templates (contemplate) to present my products instead of the core drupal/ubercart product form.
I dislike the way ubercart disregards inventory levels, you must add a stock module else ubercart thinks you have a limitless supply of widgets.
Hopefully this can help someone in the same situation as me:
In my content template I am not giving the customer a 'add to cart' button, instead I am giving the customer a 'customize' button first, then only after the customer selects their product options (for me this means text they want written on a greeting card) do I then give the customer a 'add to cart' button. However I am not using the 'add to cart' button ubercart gives me, instead I am using a custom button that adds a cart link to the cart (so I can bring all the options into the cart with the product).
So I could not use any of the other posted hacks about changing the 'add to cart' button text etc. I did however find a very useful post that pointed me in the right direction.
From content template:
//decide if the product is in stock
//if it is out of stock give a disabled out of stock button
//else provide the customize button
$stocklevel = uc_stock_level($node->model);
if ($stocklevel>1)
$productcustomizebutton="<a href=\"node/126?format=simple\" rel=\"lightmodal[|width:700px; height:500px; scrolling: none;]\"><input name=\"Button1\" type=\"button\" value=\"Customize\" /></a>";
else
$productcustomizebutton="<input name=\"Button1\" type=\"button\" disabled=\"disabled\" value=\"Out of stock\" />";the important piece here is:
$stocklevel = uc_stock_level($node->model);I did not realize that even though this variable is not advertised by contemplate, it can still be gathered by PHP from within the content template. Then it was just a easy matter of putting it together as either a 'add to cart' or a 'out of stock' button.
I only pray that the next version of ubercart does more to respect stock levels. I find the current stock incapability of ubercart to be it's only significant drawback.
