by mjbrunelle » Tue Dec 21, 2010 10:39 am
We display two prices, if the customer is registered we pull their discount from the cookie, and display their discounted price as well as the list price. You output the price information only if the customer is registered.
First In your normal javascript login script provided by SS, you have the variable "signed_in", which is read from the cookie. You will need to move this variable definition outside of the function so it is a global variable. This will make this information available when you are producing the product table.
Second you will have to set up a javascript routine to add the "PRICE" column to the output of the product table.
Change the login script to make the signed_in variable global.
<SCRIPT LANGUAGE="javascript">
var signed_in= -1;
function DisplayLogName(name) {
var cookies=document.cookie;
var start = cookies.indexOf(name + "=");
var name = "";
var start1;
var end1;
var tmp;
var signed_in = -1; {remove this line}
Then use this script:
function displayPrice( cellType, workPrice )
{
if (signedIn != -1)
{
if (cellType = "header") { document.writeln("<th class='productHeader'>PRICE</th>"); }
if (cellType = "product") { document.writeln("<td class='productPrice'>workPrice</td>"); }
}
}
</script>
In the Page Template do something like this:
<tr>
<th class="productHeader">PART NO</th>
<th class="productHeader">SIZE</th>
<th class="productHeader">PACK</th>
<th class="productHeader">SELECT</th>
<th class="productHeader">QUANTITY</th>
<script language="javascript">displayPrice('header',' ');</script>
</tr>
In the Product Template do something like this:
<td> -- other product out put variables --</td>
<script language="javascript">displayPrice('product','[-- PRODUCT.Price --]');</script>
You call the routine twice, if the customer is registered it adds the column header "PRICE" and the column price data.
MarkB