VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: VopoloS on January 24, 2016, 11:14:59 AM

Title: How to show ratingcount
Post by: VopoloS on January 24, 2016, 11:14:59 AM
How to show on the item card :
<span itemprop="ratingCount"><?php echo $ratingcount ?></span>

How to get $ratingcount
?
Virtuemart 3.0.12
Title: Re: How to show ratingcount
Post by: GJC Web Design on January 24, 2016, 12:42:30 PM
have you checked the $this->product object to see if rating is there?
Title: Re: How to show ratingcount
Post by: VopoloS on January 24, 2016, 16:03:52 PM
Quote from: GJC Web Design on January 24, 2016, 12:42:30 PM
have you checked the $this->product object to see if rating is there?
Checked. Inserted in the template file productdetails/default.php code: <?php echo $this->product->ratingcount; ?>. No data
Title: Re: How to show ratingcount
Post by: GJC Web Design on January 24, 2016, 19:36:08 PM
so there is a node called $this->product->ratingcount but it is empty?
Title: Re: How to show ratingcount
Post by: Spiros Petrakis on January 24, 2016, 19:47:33 PM
Please use this to get the number of ratings in the product page


<?php
$ratingModel 
VmModel::getModel('Ratings');
 
$productrating $ratingModel->getRatingByProduct($this->product->virtuemart_product_id);
?>

<span itemprop="ratingCount"><?php echo $productrating->ratingcount?></span>


Btw structured data is already available in the product page if you use the default virtuemart theme but you can also easily added to your template by adding this code in the product view


<?php
if ($this->product->prices['salesPrice'] > 0) {
  echo 
shopFunctionsF::renderVmSubLayout('snippets',array('product'=>$this->product'currency'=>$this->currency'showRating'=>$this->showRating));
}
?>

Title: Re: How to show ratingcount
Post by: VopoloS on January 24, 2016, 21:35:01 PM
Quote from: Spyros Petrakis on January 24, 2016, 19:47:33 PM
Please use this to get the number of ratings in the product page


<?php
$ratingModel 
VmModel::getModel('Ratings');
 
$productrating $ratingModel->getRatingByProduct($this->product->virtuemart_product_id);
?>

<span itemprop="ratingCount"><?php echo $productrating->ratingcount?></span>


Btw structured data is already available in the product page if you use the default virtuemart theme but you can also easily added to your template by adding this code in the product view


<?php
if ($this->product->prices['salesPrice'] > 0) {
  echo 
shopFunctionsF::renderVmSubLayout('snippets',array('product'=>$this->product'currency'=>$this->currency'showRating'=>$this->showRating));
}
?>



Thank you very much. It worked.