[ic] Product Rating System

Christopher Wenham cwenham at synesmedia.com
Tue Nov 18 01:28:00 EST 2003

On Monday 17 November 2003 22:40, Matthew Villa wrote:
> I'm interested in having a product rating system for Interchange.
> However, I want to limit this function to only customers who purchased
> that product. Is there any documentation or any examples available on
> how to implement that feature?

 Hmm.. This is off the top of my head, but say you're putting this somewhere 
in flypage.html, first check to see if the user is logged in:

 [if session logged_in]

 Then see if that user has ordered that product:

 [query list="1" sql="SELECT code FROM orderline WHERE user = '[data session 
username]' AND sku = '[item-code]' LIMIT 1"]

 Then write some code to save the user's rating:
 (You'll need to make the 'product_ratings' table)
[set save rating]
[import table=product_ratings type=LINE continue=NOTES]
id: [counter products/product_ratings.autonumber]
user: [data session username]
sku: [cgi sku]
rating: [cgi rating]

Then put in whatever your rating code form thingy is, and make mv_check call 
the save routine:

 <form action="[process]" method="post">
 <input type="hidden" name="mv_todo" value="return"/>
 <input type="hidden" name="mv_nextpage" value="[item-code]"/>
 <input type="hidden" name="mv_check" value="save rating"/>
 <input type="hidden" name="sku" value="[item-code]"/>

 <p>Your rating: <input type="text" size="2" name="rating"/>
 <br><input type="submit" value="Rate this"/></p>

 Then close up:


 The above code might not work the first time, I didn't really test it, but I 
think it's in the right ballpark.

Chris Wenham - Synesmedia, Inc.
516-620-4110 / 1-888-255-7573
Fax: 516-908-7824

More information about the interchange-users mailing list