Call JS function on each recommendation item

Comments

1 comment

  • Permanently deleted user

    Hi Dennis,
    I usually do something similar to this logic:

      <div class="dy_widget">
      ${#Recommendation}
      <div class="dy-item">
        <!--some html here'-->
        <div class="price" data-price="${price}" data-sale-price="${sale price}">
        </div>
      </div>
      ${/Recommendation}
    </div>
    
    var itemPrices = document.querySelectorAll('.dy_widget .price');
    for(var i=0; i<itemPrices.length; i++){
      var price = itemPrices[i].getAttribute('data-price');
      var salePrice = itemPrices[i].getAttribute('data-sale-price');
      //price calculation and html change code here
    }
    Comment actions Permalink

Please sign in to leave a comment.