PDA

View Full Version : Using a Customvar as a stock level indicator


bentleybloke
14-Jan-2004, 09:59 AM
Hi Forum.

I am hoping that there is a clever person out there can tell me how to modify the regular stock level script so that a customvar can be included which would give more range to the out of stock message... an indication of how long it will take for fresh stock to arrive from various suppliers. i.e. 1-3 days, 4-7 days etc.

An example of what I want to do can be found on the overclockers website http://www.overclockers.co.uk. They use images as the stock indicator and unless they manage this manually, I presume that the various lead times are defined as a CUSTOMVAR.

The script I have at the minute (from the AUG) reads:


<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
function StockLevels(pItem)
<!--
{
var strIDs = 'Stock Message: '
{
if (pItem >= 10)
{
strIDs = 'Normally Ships in 24 Hours'
}
else
{
strIDs = 'Normally ships in 1-2 weeks'
}
}
return strIDs
}
//-->
</script>


How, if possible, could I include the CUSTOMVAR in this?


Thanks in advance!

NormanRouxel
14-Jan-2004, 01:24 PM
I thnk this was covered on the Forum recently.

Anyway you can use CUSTOMVARS in JavaScript as long as that JavaScript is in a Product Template.

e.g.


<script language=JavaScript>
<!--
// get the customvar
var message="CUSTOMVAR:MYMESSAGE";
// if it's blank or not defined use a default message
if ( message == '' ) message = 'My default message...';
// display the message
document.write(message);
// -->
</script>


Norman

bentleybloke
16-Jan-2004, 01:16 PM
Many thanks Norman, just the job!


Jonathan.

jxm28788
28-Oct-2006, 11:59 AM
Is there a way to use this if a certain item is in the basket?

OR

Is there a way to set a global variable at the point a specific item is added to the basket? (and then use the if statement to query the global variable)

Nadeem
31-Oct-2006, 09:14 AM
Hi John

I'm afraid this would require a bit of customisation, poss even in the perlscripts as well. If there is anyone who has done this, then please comment to this thread.

Kind Regards