Create an account to edit articles | See Formatting Syntax for Wiki syntax | We look forward to your contribution!
You are here: The ProductCart Encyclopedia » how-to » low_stock_message » Showing a Low Stock Message
Showing a Low Stock Message
This comes in handy when you only want to show stock levels or a message stating “Low Stock” when the stock level for an item falls below a particular level. The standard behavior is to show or hide inventory information, regardless of a particular inventory level.
Source Code Changes
The code below is for V3.51 and is for standard products. If you wish to achieve the same result for BTO or Apparel products then check the code relating to those as it may be different.
Existing Code in pc/ViewPrdCode.asp:
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' START: Show Units in Stock (if on, show the stock level here) '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Public Sub pcs_UnitsStock if scdisplayStock=-1 AND pNoStock=0 then if pstock > 0 then response.write "<div class='pcShowProductStock'>" response.write dictLanguage.Item(Session("language")&"_viewPrd_19") & " " & pStock response.write "</div>" end if end if End Sub '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' END: Show Units in Stock (if on, show the stock level here) '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
… would become:
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' START: Show Units in Stock (if on, show the stock level here) '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Public Sub pcs_UnitsStock if scdisplayStock=-1 AND pNoStock=0 then ' COMPANY XYZ EDITS - START ' if pstock > 0 then <<<< ORIGINAL-CODE if pstock > 0 AND pstock < 41 then COMPANY XYZ EDITS - END response.write "<div class='pcShowProductStock'>" ' COMPANY XYZ EDITS - START ' response.write dictLanguage.Item(Session("language")&"_viewPrd_19") & " " & pStock <<<< ORIGINAL-CODE response.write dictLanguage.Item(Session("language")&"_viewPrd_19") ' COMPANY XYZ EDITS - END response.write "</div>" end if end if End Sub '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' END: Show Units in Stock (if on, show the stock level here) '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Note:
- the removal of the stock level from the message that is written out to the page
- an IF statement limiting the message to being shown when the stock level is between 1 and 40
- of course you can set whatever levels or message you desire.
Also not the use of the “COMPANY XYZ EDITS ” comments. It is important to always, clearly comment any code edits, as mentioned in our guidelines for editing ProductCart's source code and prepare for future updates.
Trace: » How to Disable the CAPTCHA Code on the Contact Us and Tell-a-Friend Forms » Using Google Analytics with your ProductCart-powered store » Managing Drop-Shippers » Store Settings: Company Details » Tabbed Product Details Display » How ProductCart is licensed » Editing Rights » Modifying a Product » Global Changes: Changing Multiple Products at Once » Showing a Low Stock Message