Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

187
Vistas
Custom JS variable for GTM

This i need to return for product page

And this i have to return for listing pages, trough loop

    function() {
  var prodRate=document.querySelector('div.summary.entry-summary > div.woocommerce-product-rating > p').innerText.replace('Product Rate:','');
  var rating = document.querySelectorAll('.star-rating');
  var starRating =[];
  for(i=0;i<rating.length;i++){
  starRating.push(rating[i].innerText)};
  
  var averageRating = starRating || prodRate;  

 return averageRating;
}

I have to return one of the values that is displayed as product rating. On listing page this rating is displayed as "aria-label", and on product page as the value of p. How can i set a one single variable, that returns the needed value of product rating. I am traying above mentioned function, but it doesn't work properly. Thank you a lot and sorry for such newbie question.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda