How to show on the item card :
<span itemprop="ratingCount"><?php echo $ratingcount ?></span>
How to get $ratingcount
?
Virtuemart 3.0.12
have you checked the $this->product object to see if rating is there?
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
so there is a node called $this->product->ratingcount but it is empty?
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));
}
?>
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.