simberak Posted September 15, 2016 Share Posted September 15, 2016 (edited) 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 September 18, 2016 by simberak (see edit history) Link to comment Share on other sites More sharing options...
rocky Posted September 18, 2016 Share Posted September 18, 2016 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 More sharing options...
simberak Posted September 18, 2016 Author Share Posted September 18, 2016 Hello rocky, tahnks for the answer. I made it like you said and it shows (0) even on product page where there is one comment... Dont you know why? Link to comment Share on other sites More sharing options...
rocky Posted September 18, 2016 Share Posted September 18, 2016 Perhaps you have an older version of the Product Comments module? It's working fine on my PrestaShop v1.6.1.7 test site: 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 More sharing options...
simberak Posted September 18, 2016 Author Share Posted September 18, 2016 Hello, thank you for your reply. I have version 3.5.2 and have that the code you posted :/ Oh Strange! Now it shows the number right So it is working So thank you again 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now