Jump to content

productcomments module: custom criterion appears as "Grade"


garyjj127

Recommended Posts

I have an odd problem. I have the productcomments module installed, and have added 2 criterion "Fit" and "Quality". They show up fine when a customer writes a review, and appear with stars next to them. However, when the review shows up on the site, instead of the "Fit" and "Quality" criterion showing, it just says "Grade". I've checked my files and they seem OK, and it also happens in the default theme, so I guess I can rule out my own theme being the problem.

 

By the way, I'm using productcomments V2.4 and Presta 1.5.6.1

 

Any help appreciated!

Edited by garyjj127 (see edit history)
Link to comment
Share on other sites

Change this (file /themes/your_theme/modules/productcomments/productcomments.tpl):

<div class="comment_author">
	<span>{l s='Grade' mod='productcomments'}&nbsp</span>
	<div class="star_content clearfix">
	{section name="i" start=0 loop=5 step=1}
		{if $comment.grade le $smarty.section.i.index}
			<div class="star"></div>
		{else}
			<div class="star star_on"></div>
		{/if}
	{/section}
	</div>
	<div class="comment_author_infos">
		<strong>{$comment.customer_name|escape:'html':'UTF-8'}</strong><br/>
		<em>{dateFormat date=$comment.date_add|escape:'html':'UTF-8' full=0}</em>
	</div>
</div>

to this:

<div class="comment_author">
{foreach from=$criterions item='criterion'}
	<span>{$criterion.name}&nbsp</span>
	<div class="star_content clearfix">
	{section name="i" start=0 loop=5 step=1}
		{if $comment.grade le $smarty.section.i.index}
			<div class="star"></div>
		{else}
			<div class="star star_on"></div>
		{/if}
	{/section}
	</div><br/>
{/foreach}
	<div class="comment_author_infos">
		<strong>{$comment.customer_name|escape:'html':'UTF-8'}</strong><br/>
		<em>{dateFormat date=$comment.date_add|escape:'html':'UTF-8' full=0}</em>
	</div>
</div>

Although it currently works fine only if both grades are the same. If they're different it shows average on both. Working on that...

Edited by Sharak (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 6 months later...
  • 1 year later...

hi everybody

i changed the productcomments.tpl and the result with separated criterions are fine
but to integrate the variables inside this array ( productcomments.php ) i don't found some solution
 
maybe someone can help me out ?
 
many thanks in advance
 
greetings marc
 
criterion_grade.png

	public function hookProductTabContent($params)
	{
		$this->context->controller->addJS($this->_path.'js/jquery.rating.pack.js');
		$this->context->controller->addJS($this->_path.'js/jquery.textareaCounter.plugin.js');
		$this->context->controller->addJS($this->_path.'js/productcomments.js');

		$id_guest = (!$id_customer = (int)$this->context->cookie->id_customer) ? (int)$this->context->cookie->id_guest : false;
		$customerComment = ProductComment::getByCustomer((int)(Tools::getValue('id_product')), (int)$this->context->cookie->id_customer, true, (int)$id_guest);

		$averages = ProductComment::getAveragesByProduct((int)Tools::getValue('id_product'), $this->context->language->id);
		$averageTotal = 0;
		foreach ($averages as $average)
			$averageTotal += (float)($average);
		$averageTotal = count($averages) ? ($averageTotal / count($averages)) : 0;
		
		$product = $this->context->controller->getProduct();
		$image = Product::getCover((int)Tools::getValue('id_product'));
		$cover_image = $this->context->link->getImageLink($product->link_rewrite, $image['id_image'], 'medium_default');
		
		$this->context->smarty->assign(array(
			'logged' => $this->context->customer->isLogged(true),
			'action_url' => '',
			'product' => $product,
			'comments' => ProductComment::getByProduct((int)Tools::getValue('id_product'), 1, null, $this->context->cookie->id_customer),
			'criterions' => ProductCommentCriterion::getByProduct((int)Tools::getValue('id_product'), $this->context->language->id),
			'averages' => $averages,
			'product_comment_path' => $this->_path,
			'averageTotal' => $averageTotal,
			'allow_guests' => (int)Configuration::get('PRODUCT_COMMENTS_ALLOW_GUESTS'),
			'too_early' => ($customerComment && (strtotime($customerComment['date_add']) + Configuration::get('PRODUCT_COMMENTS_MINIMAL_TIME')) > time()),
			'delay' => Configuration::get('PRODUCT_COMMENTS_MINIMAL_TIME'),
			'id_product_comment_form' => (int)Tools::getValue('id_product'),
			'secure_key' => $this->secure_key,
			'productcomment_cover' => (int)Tools::getValue('id_product').'-'.(int)$image['id_image'],
			'productcomment_cover_image' => $cover_image,
			'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')),
			'nbComments' => (int)ProductComment::getCommentNumber((int)Tools::getValue('id_product')),
			'productcomments_controller_url' => $this->context->link->getModuleLink('productcomments'),
			'productcomments_url_rewriting_activated' => Configuration::get('PS_REWRITING_SETTINGS', 0),
			'moderation_active' => (int)Configuration::get('PRODUCT_COMMENTS_MODERATE')
	   ));

		$this->context->controller->pagination((int)ProductComment::getCommentNumber((int)Tools::getValue('id_product')));
		
		return ($this->display(__FILE__, '/productcomments.tpl'));
		
	}
<div id="idTab5">
	<div id="product_comments_block_tab">
		{if $comments}
			{foreach from=$comments item=comment}
				{if $comment.content}
				<div class="comment row" itemprop="review" itemscope itemtype="https://schema.org/Review">
					<div class="comment_author col-sm-2">
						{foreach from=$criterions item='criterion'}
							<span>{$criterion.name}</span>
							<div class="star_content clearfix">
								{section name="i" start=0 loop=5 step=1}
									{if $test le $smarty.section.i.index}
										<div class="star"></div>
									{else}
										<div class="star star_on"></div>
									{/if}
								{/section}
							</div><br/>
						{/foreach}
							<div class="comment_author_infos">
								<strong>{$comment.customer_name|escape:'html':'UTF-8'}</strong><br/>
								<em>{dateFormat date=$comment.date_add|escape:'html':'UTF-8' full=0}</em>
							</div>
					</div> <!-- .comment_author -->
Link to comment
Share on other sites

  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...