Disabling the Add to Cart Button on Pages

General ShopSite user discussion

Disabling the Add to Cart Button on Pages

Postby apegamer » Fri Oct 08, 2010 11:34 am

It would really be nice to be able to automatically turn off the Add to Cart button for products that are out of stock. Sure, I can use spacer.gif on the product page, but what about on category pages that show multiple products?
apegamer
 
Posts: 5
Joined: Thu Oct 29, 2009 6:38 pm
Location: Houston, TX

Re: Disabling the Add to Cart Button on Pages

Postby Jim » Fri Oct 08, 2010 1:20 pm

Modify your product template to check the quantity on hand field of the product (Pro level only) and if the quantity is 0 then instead of outputting the normal add to cart button output an Out of Stock image or some text that says it is out of stock.

If you don't have a Pro level store you can create a separate Out of Stock product template that doesn't have the add to cart button. When you no longer have any of the product just change the product template to that one and republish.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Re: Disabling the Add to Cart Button on Pages

Postby apegamer » Fri Oct 08, 2010 2:27 pm

Thanks, I can do that.
apegamer
 
Posts: 5
Joined: Thu Oct 29, 2009 6:38 pm
Location: Houston, TX

Re: Disabling the Add to Cart Button on Pages

Postby specialtygraphics » Thu Jun 23, 2011 8:17 am

Not sure if I will get a response as this thread is a little old. But Jim I have set it to run as you stated for the Pro version. It works for the most part, however with one small glitch.

Code: Select all
[-- IF PRODUCT.QuantityOnHand "0" --]
        <span style="color:red; font-size:16px;">Out of Stock</span>
[-- ELSE --]
   <input type="image" name="Submit" src="[-- VAR.MyImages --]/images/btnAddToCartMi.gif" id="btnAddToCartMi">
[-- END_IF --]


This was the following code I used however once the quantity on hand reaches the the low stock threshold it will show it out of stock. Obviously we can set that to 0 as well and it would work perfectly, but we have no warning of the item being low before it's out of stock.

An example in case you don't understand what I'm saying. We have 10 widgets in stock and the low stock threshold is 5 and out of stock is 0. We sell 5 and meet the low stock threshold. It then marks the item out of stock even though we still have 5 in stock.

Should I be testing the quantity on hand in a different way such as comparing it to the out of stock quantity. If so would you happen to know the code i would use to compare the two.
specialtygraphics
 
Posts: 20
Joined: Wed Oct 14, 2009 11:35 am
Location: Illinois

Re: Disabling the Add to Cart Button on Pages

Postby Jim » Thu Jun 23, 2011 10:36 am

First question, do you have ShopSite Inventory Tracking enabled in ShopSite? (Preferences > Inventory Tracking). The inventory values in the product (On Hand, Low Stock, Out of Stock) are only maintained if ShopSite Inventory Tracking is enable. If you are using a Custom Inventory Tracking Add-on or have None selected then the values are not used at all.

Also you have your Out of Stock limit set to less than 0, so the Quantity On Hand value could go to a negative value, then the code you posted would not work. But if you have the Out of Stock limit set to 0 then the code should work. The Quantity on Hand would never get below 0 because once the Quantity on hand got to 0 shoppers would not be allowed to order the item.

The Low stock threshold would not affect the functioning of this template tag
[-- IF PRODUCT.QuantityOnHand "0" --] .

If you want to compare the Low stock limit you could probably assign it to a VAR and then compare the VAR to the QuantityOnHand. Something like this (but I haven't tested it)

[-- VAR.Limit PRODUCT.OutOfStockLimit --]
[-- IF PRODUCT.QuantityOnHand VAR.Limit --] .
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah


Return to User Forum

Who is online

Users browsing this forum: No registered users and 10 guests