Jump to content

[SOLVED] Product Comments TAB - adding a number of comments to Tab


Recommended Posts

Hello,

 

I wiuld like to add the number of comments into the Tab of Product Comments at product page. Do somebody have an idea, how to achieve that? And by the best to add the number only if there is more than 0 comments :)

 

So the tab will look like:

Reviews (9)

 

Thank for help,

 

Daniel

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

Edit themes/default-bootstrap/modules/productcomments/tab.tpl and change line 26 from:

<h3 id="#idTab5" class="idTabHrefShort page-product-heading">{l s='Reviews' mod='productcomments'}</h3> 

to:

<h3 id="#idTab5" class="idTabHrefShort page-product-heading">{l s='Reviews' mod='productcomments'} ({$nbComments})</h3>
Link to comment
Share on other sites

Perhaps you have an older version of the Product Comments module? It's working fine on my PrestaShop v1.6.1.7 test site:

post-13933-0-72426100-1474202572_thumb.png

 

Here's the code I see in modules/productcomments/productcomments.php that creates the $nbComments variable:

	public function hookProductTab($params)
	{
		require_once(dirname(__FILE__).'/ProductComment.php');
		require_once(dirname(__FILE__).'/ProductCommentCriterion.php');

		$average = ProductComment::getAverageGrade((int)Tools::getValue('id_product'));

		$this->context->smarty->assign(array(
											'allow_guests' => (int)Configuration::get('PRODUCT_COMMENTS_ALLOW_GUESTS'),
											'comments' => ProductComment::getByProduct((int)(Tools::getValue('id_product'))),
											'criterions' => ProductCommentCriterion::getByProduct((int)(Tools::getValue('id_product')), $this->context->language->id),
											'averageTotal' => round($average['grade']),
											'nbComments' => (int)(ProductComment::getCommentNumber((int)(Tools::getValue('id_product'))))
									   ));

		return ($this->display(__FILE__, '/tab.tpl'));
	}

Check to make sure you have the same code.

Link to comment
Share on other sites

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...