WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Bakery Shop »
  • No "add to cart" button if stock = 0 please?
  • Print
Pages: [1]   Go Down

Author Topic: No "add to cart" button if stock = 0 please?  (Read 12223 times)

Offline CodeALot

  • Posts: 579
  • Gender: Male
No "add to cart" button if stock = 0 please?
« on: September 11, 2013, 05:11:35 PM »
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?
Logged

Offline marmot

  • Posts: 1103
Re: No "add to cart" button if stock = 0 please?
« Reply #1 on: October 08, 2013, 09:56:13 PM »
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
Code: [Select]
<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:
Code: [Select]
[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
Logged

Offline CodeALot

  • Posts: 579
  • Gender: Male
Re: No "add to cart" button if stock = 0 please?
« Reply #2 on: October 11, 2013, 01:40:15 PM »
Looks like a nice solution, thanks a lot!
Logged

Offline CodeALot

  • Posts: 579
  • Gender: Male
Re: No "add to cart" button if stock = 0 please?
« Reply #3 on: December 19, 2016, 12:37:15 PM »
(Never mind. My bad. :)
« Last Edit: December 19, 2016, 12:49:00 PM by CodeALot »
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Bakery Shop »
  • No "add to cart" button if stock = 0 please?
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2