X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Restrict Voting and Reviews to Registered Customers Only (https://forum.x-cart.com/showthread.php?t=16844)

salsabeel 09-24-2005 06:16 PM

Restrict Voting and Reviews to Registered Customers Only
 
From what I could find, X-Cart lets you select under Modules Options the ability to allow only registered customers to Write Reviews, but even when you set this it still allows unregistered customers to set a Ranking. I needed to make it to where only registered customers can both write reviews and set rankings because otherwise anonymous users could set rankings and possibly ruin product ratings, defeating the whole purpose of the feature. Also I wanted to make it to where unregistered customers would still be able to view the rankings and reviews that were made by registered customers.

Firstly, make sure you have Customer Reviews turned on under Modules. Also turn on Allow viewing reviews, Allow voting, and Allow adding reviews under Modules Options.

Secondly, edit the file: /modules/Customer_Reviews/vote_reviews.tpl

Code:

{* $Id: vote_reviews.tpl,v 1.3.2.2 2005/08/10 11:00:42 mclap Exp $ *}
{if $config.Modules.customer_voting eq "Y" || ($config.Modules.customer_reviews eq "Y" && ($reviews ne "" || $config.Modules.writing_reviews eq "A" || ($login ne "" && $config.Modules.writing_reviews eq "R")))}
{capture name=dialog}
<TABLE width="100%" border="0" cellpadding="0" cellspacing="0">
{if $config.Modules.customer_voting eq "Y"}
{include file="modules/Customer_Reviews/vote.tpl"}
<TR><TD colspan="2">

</TD></TR>
{/if}
{if $config.Modules.customer_reviews eq "Y"}
{include file="modules/Customer_Reviews/reviews.tpl"}
{/if}
</TABLE>
{/capture}
{include file="dialog.tpl" content=$smarty.capture.dialog title=$lng.lbl_customers_rating extra="width=100%"}
{/if}


Copy and paste the following code to replace the previous code:

Code:

{* $Id: vote_reviews.tpl,v 1.3.2.2 2005/08/10 11:00:42 mclap Exp $ *}
{if $login ne "" && $config.Modules.writing_reviews eq "R"}
{capture name=dialog}
<TABLE width="100%" border="0" cellpadding="0" cellspacing="0">
{if $config.Modules.customer_voting eq "Y"}
{include file="modules/Customer_Reviews/vote.tpl"}
<TR><TD colspan="2">

</TD></TR>
{/if}
{if $config.Modules.customer_reviews eq "Y"}
{include file="modules/Customer_Reviews/reviews.tpl"}
{/if}
</TABLE>
{/capture}
{include file="dialog.tpl" content=$smarty.capture.dialog title=$lng.lbl_customers_rating extra="width=100%"}
{else}
{capture name=dialog}
<TABLE width="100%" border="0" cellpadding="0" cellspacing="0">
<TR><TD colspan="2">
<FONT class="ProductDetailsTitle">{$lng.lbl_customers_rating}</FONT>
</TD></TR>
<TR><TD class="Line" height="1" colspan="2">[img]{$ImagesDir}/spacer.gif[/img]</TD></TR>
{if $vote_max_cows ne ""}
<TR>
<TD>
{$lng.lbl_customers_rating}</TD>
<TD>

{section name=full_cows loop=$vote_max_cows}
[img]{$ImagesDir}/star_4.gif[/img]
{/section}
{if $vote_little_cow ne "0"}
[img]{$ImagesDir}/star_{$vote_little_cow}.gif[/img]
{/if}
{section name=free_cows loop=$vote_free_cows}
[img]{$ImagesDir}/star_0.gif[/img]
{/section}
</TD></TR>{/if}
<TR><TD colspan="2">

<FONT class="ProductDetailsTitle">{$lng.lbl_customer_reviews}</FONT>
</TD></TR>
<TR><TD class="Line" height="1" colspan="2">[img]{$ImagesDir}/spacer.gif[/img]</TD></TR>
{section name=r_i loop=$reviews}
<TR>
<TD colspan="2">
{$lng.lbl_author}: {$reviews[r_i].email|default:$lng.lbl_unknown}
{$reviews[r_i].message|replace:"\n":"
"}

</TD></TR>
{/section}
</TABLE>
{/capture}
{include file="dialog.tpl" content=$smarty.capture.dialog title=$lng.lbl_customers_rating extra="width=100%"}
{/if}


There may be a shorter way to do this but this is my first customization for X-Cart that I have posted and I am still new to Smarty. From my tests it works for me perfect, but please let me know if it doesn't work for you.

kpayne 10-11-2005 12:47 PM

Thanks for this!


All times are GMT -8. The time now is 04:19 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.