Author Topic: How to show ratingcount  (Read 2065 times)

VopoloS

  • Jr. Member
  • **
  • Posts: 55
How to show ratingcount
« on: January 24, 2016, 11:14:59 am »
How to show on the item card :
Code: [Select]
<span itemprop="ratingCount"><?php echo $ratingcount ?></span>
How to get $ratingcount
?
Virtuemart 3.0.12

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 10451
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: How to show ratingcount
« Reply #1 on: January 24, 2016, 12:42:30 pm »
have you checked the $this->product object to see if rating is there?
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

VopoloS

  • Jr. Member
  • **
  • Posts: 55
Re: How to show ratingcount
« Reply #2 on: January 24, 2016, 16:03:52 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

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 10451
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: How to show ratingcount
« Reply #3 on: January 24, 2016, 19:36:08 pm »
so there is a node called $this->product->ratingcount but it is empty?
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Spiros Petrakis

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 103
    • yourgeek.gr
  • VirtueMart Version: Always latest Stable
Re: How to show ratingcount
« Reply #4 on: January 24, 2016, 19:47:33 pm »
Please use this to get the number of ratings in the product page

Code: [Select]
<?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

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

Joomla templates and extensions development
https://www.yourgeek.gr

VopoloS

  • Jr. Member
  • **
  • Posts: 55
Re: How to show ratingcount
« Reply #5 on: January 24, 2016, 21:35:01 pm »
Please use this to get the number of ratings in the product page

Code: [Select]
<?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

Code: [Select]
<?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.