No "add to cart" button if stock = 0 please?

CodeALot

#4
(Never mind. My bad. :)

CodeALot


marmot

Hi,

not exactly what you aked for but in bakery 1.7 (maybe works in 1.6 too) I used some js to disable the "add to chart" button and set the caption "Sold out!". This only works when the option to "show stock to customers" is enabled in the common options as you need to get the [STOCK] placeholder resolved.
So in the page options I added one line of js each that all together looks like (I paste all the code to show the context I used, its bakery 1.7 standard):
overview loop<td class="mod_bakery_main_td_f">
[THUMB]
<br />
<a href="[LINK]"><span class="mod_bakery_main_title_f">[TITLE]</span></a>
<br />
[DESCRIPTION]
<br />
[TXT_PRICE]: [CURRENCY] [PRICE]
<br />
[TXT_STOCK]: [STOCK]
<br />
<form action="[SHOP_URL]" method="post">
[OPTION]
<br />
<input type="text" name="item[ITEM_ID]" class="mod_bakery_main_input_f" value="1" size="2" />
<input type="submit" name="add_to_cart" class="mod_bakery_bt_add_f" value="[ADD_TO_CART]" />
</form>
added--->>>> <script>if ([STOCK]===0) {$('.mod_bakery_bt_add_f').last().val('Sold out!').attr("disabled", true);};</script>
</td>
detail footer:[IMAGE]
<form action="[SHOP_URL]" method="post">
<table border="0" cellspacing="0" cellpadding="5" class="mod_bakery_item_table_f">
<tr>
<td colspan="2" align="left" valign="top"><h2 class="mod_bakery_item_title_f">[TITLE]</h2></td>
</tr>
<tr>
<td align="left" valign="top"><span class="mod_bakery_item_sku_f">[TXT_SKU]:</span></td>
<td align="left" valign="top">[SKU]</td>
</tr>
<tr>
<td align="left" valign="top"><span class="mod_bakery_item_price_f">[TXT_PRICE]:</span></td>
<td align="left" valign="top">[CURRENCY] [PRICE]</td>
</tr>
<tr>
<td align="left" valign="top"><span class="mod_bakery_item_shipping_f">[TXT_SHIPPING]:</span></td>
<td align="left" valign="top">[CURRENCY] [SHIPPING] </td>
</tr>
<tr>
<td align="left" valign="top"><span class="mod_bakery_item_stock_f">[TXT_STOCK]:</span></td>
<td align="left" valign="top">[STOCK]</td>
</tr>
<tr>       
<td align="left" valign="top"><span class="mod_bakery_item_full_desc_f"><p>[TXT_FULL_DESC]:</p></span></td>
<td align="left" valign="top">[FULL_DESC]</td>
</tr>
<tr>       
<td align="left" valign="top"><span class="mod_bakery_shipping_cost_f">[TXT_SHIPPING_COST]:</span></td>
<td align="left" valign="top">
[TXT_DOMESTIC]: [CURRENCY] [SHIPPING_DOMESTIC]<br />
[TXT_ABROAD]: [CURRENCY] [SHIPPING_ABROAD]</td>
</tr>
[OPTION]
<tr>     
<td align="left" valign="top"> </td>
<td align="left" valign="top">
<input type="text" name="item[ITEM_ID]"  class="mod_bakery_item_input_f" value="1" size="2" />
<input type="submit" name="add_to_cart" class="mod_bakery_bt_add_f" value="[ADD_TO_CART]" />
</td>
</tr>
</table>
</form>
[PREVIOUS] | <a href="[BACK]">[TXT_BACK]</a> | [NEXT]
</center>
<br />
added--->>>>  <script>if ([STOCK]===0) {$('.mod_bakery_bt_add_f').val('Sold out!').attr("disabled", true);};</script>


regards

CodeALot

I'm still using Bakery 1.6 since 1.7 caused problems I have to look into.

I set the "Allow ordering out of stock items" to "NO", and what happens now is that my customer clicks "Add to cart" and the site yells in RED "SHOPPING CART IS EMPTY" because there was no stock.

That's not the way to handle it. There shouldn't be a "Add to cart" button at all. Is there a way to achieve that?