Easy way to hide prices when not logged in?

General ShopSite user discussion

Easy way to hide prices when not logged in?

Postby MgmtSpec » Mon Dec 20, 2010 10:46 pm

Hi,

Looking for a way to hide pricing UNLESS the registered user logs in.
MgmtSpec
 
Posts: 204
Joined: Mon Apr 30, 2007 8:25 am

Re: Easy way to hide prices when not logged in?

Postby 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
mjbrunelle
 
Posts: 147
Joined: Sun Jun 21, 2009 5:09 am

Re: Easy way to hide prices when not logged in?

Postby MgmtSpec » Tue Dec 21, 2010 12:06 pm

Looks like what I need - I'll give it a try!
MgmtSpec
 
Posts: 204
Joined: Mon Apr 30, 2007 8:25 am

Re: Easy way to hide prices when not logged in?

Postby MgmtSpec » Tue Apr 19, 2011 11:02 pm

What do you do about the "Add to Cart" button/link? That would also need to be hidden. Also, what about internal "Search Results"? Wouldn't that template also need to hide price?
MgmtSpec
 
Posts: 204
Joined: Mon Apr 30, 2007 8:25 am

Re: Easy way to hide prices when not logged in?

Postby Jim » Wed Apr 20, 2011 8:52 am

You could probably do the same thing on the product template used for search.

Note however that since the pages are static the info isn't being pulled in real-time. It will still be on the html page but just hidden when someone isn't logged in. If they viewed the pages source they could probably still see the prices.
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 75 guests