I have received numerous requests for some code I wrote to password protect a product page in Miva Merchant 5 (or 5.5), so I thought I’d share it here. This code was originally written for a site that wanted to implement custom product pricing using the Emporium Plus External Product Purchase module, but wanted to ensure that only staff members could access the page.
Note: This code requires the Tool Kit from Emporium Plus. If you have a Miva Merchant 5 (or 5.5) store, the Tool Kit is an immensely valuable module that allows developers and store owners enormous flexibility in customizing their stores. It is beyond worth the money (and no, I don’t get anything for saying so except the satisfaction of spreading the word about an extremely useful tool).
To use the code below:
- Set up an availability group, and assign authorized customers to this group.
- Substitute your desired product code where indicated by the text YOUR_PRODUCT_CODE_HERE (2 places).
- Substitute your availability group name (not code!) for the AVAILABILITY_GROUP_NAME in the code below.
This code is designed to work on the main screen of the regular PROD page. If you’re using a template manager, you can remove the conditional that tests for the product code.
If you’re using Miva 5 (instead of 5.5), you’ll want to replace <mvt:item name=”html_profile” /> with <html> and <mvt:item name=”head” param=”head_tag” /> with <mvt:item name=”head” />
<mvt:item name="html_profile" />
<head>
<title>&mvt:store:name;: &mvt:product:name;</title>
<base href="&mvt:global:basehref;">
<mvt:item name="head" param="head_tag" />
</head>
<mvt:item name="body">
<mvt:item name="hdft" param="global_header" />
<tr><td align="left" valign="bottom">
<mvt:item name="hdft" param="header" />
</td></tr>
<tr><td align="left" valign="top" bgcolor="&mvt:colors:ctgy_bg;">
<table border="0" cellpadding="10" cellspacing="0">
<tr><td align="left" valign="top" nowrap>
<mvt:item name="fonts" param="ctgy_font">
<mvt:item name="customerlink" />
<mvt:item name="affiliatelink" />
<mvt:item name="category_tree" />
</mvt:item>
</td></tr>
</table>
</td><td align="left" valign="top" width="80%">
<br>
<blockquote>
<mvt:comment>Test for desired product code</mvt:comment>
<mvt:if expr="l.settings:product:code EQ 'YOUR_PRODUCT_CODE_HERE'">
<mvt:comment>Check to see if customer is logged in</mvt:comment>
<mvt:if expr="g.Basket:CUST_ID">
<mvt:comment>Check to see if customer is a member of your availability group</mvt:comment>
<mvt:item name="toolkit" param="agroup|acount" />
<mvt:foreach iterator="customer_agroup" array="customer_agroups">
<mvt:comment>Set test variable for use later in the page</mvt:comment>
<mvt:if expr="l.settings:customer_agroup:name EQ 'YOUR_AVAILABILITY_GROUP'">
<mvt:item name="toolkit" param="sassign|staffid|1" />
<mvt:item name="prod_ctgy_hdft" param="prod_header" />
<mvt:item name="prod_ctgy_hdft" param="prod_header" />
<mvt:item name="product_display" />
<mvt:if expr="l.settings:product_count NE 0">
<br><br>
<mvt:item name="fonts" param="hdr_font">
<b>Related Item(s)</b><br>
</mvt:item>
<mvt:item name="product_list" />
</mvt:if>
<mvt:item name="prod_ctgy_hdft" param="prod_footer" />
</blockquote>
</mvt:if>
</mvt:foreach> <mvt:comment>End Availability Group Array</mvt:comment>
</mvt:if> <mvt:comment>End display product details if in Availability Group</mvt:comment>
<mvt:comment>If customer is logged in but staffid variable not set, display continue shopping link</mvt:comment>
<mvt:if expr="g.Basket:CUST_ID AND (g.staffid NE '1')">
<p>This page is for internal use only.</p><br><br><br>
<p><a href="http://domain.com"><img src="graphics/00000001/continue_shopping.jpg" alt="Continue Shopping"></a></p>
<mvt:comment>Otherwise, if customer is not logged in, display login</mvt:comment>
<mvt:elseif expr="g.staffid NE '1'">
<p>This page is for internal use only. Staff members may log in below.</p>
<form method="post" action="&mvt:global:secure_sessionurl;">
<input type="hidden" name="Store_Code" value="&mvte:store:code;">
<input type="hidden" name="Screen" value="PROD">
<input type="hidden" name="Product_Code" value="YOUR_PRODUCT_CODE_HERE">
<label for="user">Username</label>
<input type="text" id="user" size="20" name="Customer_Login" value="&mvte:global:Customer_Login;">
<br><br>
<input type="radio" name="Action" value="LOGN" checked="checked" style="display: none;">
<label for="pass">Password:</label>
<input type="password" id="pass" size="20" name="Customer_Password">
<br><br>
<mvt:item name="buttons" param="Login" />
<br><br>
</form>
</mvt:if>
<mvt:comment>For all other products, display the regular layout</mvt:comment>
<mvt:else>
<mvt:item name="product_display" />
<mvt:if expr="l.settings:product_count NE 0">
<br><br>
<mvt:item name="fonts" param="hdr_font">
<b>Related Item(s)</b>
<br>
</mvt:item>
<mvt:item name="product_list" />
</mvt:if>
<mvt:item name="prod_ctgy_hdft" param="prod_footer" />
</blockquote>
</mvt:if> <mvt:comment>End conditional to test for product code<mvt:comment>
</td></tr>
<tr><td align="left" valign="bottom">
<mvt:item name="hdft" param="footer" />
</td></tr>
</table>
<mvt:item name="hdft" param="global_footer" />
</mvt:item>
</html>

You’ve got a really great website and very informational blog Leanne. Wow. I should visit here more often!
Shari
This is a great tip! And the toolkit is definitely invaluable.