Advertisement
Guest User

Untitled

a guest
Feb 27th, 2019
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Smarty 2.01 KB | None | 0 0
  1.     {if $reviews}
  2.         {math equation="floor(x)" x=$snippetData.avarageRating assign=averageAll}
  3.         {assign var="countAll" value=$reviews|@count}
  4.  
  5.         {assign var="count1" value=0}
  6.         {assign var="count2" value=0}
  7.         {assign var="count3" value=0}
  8.         {assign var="count4" value=0}
  9.         {assign var="count5" value=0}
  10.         {foreach from=$reviews item="review"}
  11.             {if $review.rating eq 1}
  12.                 {assign var='count1' value=$count1+1}
  13.             {elseif $review.rating eq 2}
  14.                 {assign var='count2' value=$count2+1}
  15.             {elseif $review.rating eq 3}
  16.                 {assign var='count3' value=$count3+1}
  17.             {elseif $review.rating eq 4}
  18.                 {assign var='count4' value=$count4+1}
  19.             {elseif $review.rating eq 5}
  20.                 {assign var='count5' value=$count5+1}
  21.             {/if}
  22.         {/foreach}
  23.         {math equation="floor((count / all) * 100)" count=$count1 all=$countAll assign="starPercent1"}
  24.         {math equation="floor((count / all) * 100)" count=$count2 all=$countAll assign="starPercent2"}
  25.         {math equation="floor((count / all) * 100)" count=$count3 all=$countAll assign="starPercent3"}
  26.         {math equation="floor((count / all) * 100)" count=$count4 all=$countAll assign="starPercent4"}
  27.         {math equation="floor((count / all) * 100)" count=$count5 all=$countAll assign="starPercent5"}
  28.  
  29.         <h1>starPercent1: {$starPercent1}%</h1>
  30.         <h1>starPercent2: {$starPercent2}%</h1>
  31.         <h1>starPercent3: {$starPercent3}%</h1>
  32.         <h1>starPercent4: {$starPercent4}%</h1>
  33.         <h1>starPercent5: {$starPercent5}%</h1>
  34.  
  35.         <h1>countAll: {$countAll}</h1>
  36.         <h1>count1: {$count1}</h1>
  37.         <h1>count2: {$count2}</h1>
  38.         <h1>count3: {$count3}</h1>
  39.         <h1>count4: {$count4}</h1>
  40.         <h1>count5: {$count5}</h1>
  41.  
  42.         <h1>averageAll: {$averageAll}</h1>
  43.  
  44.         {if $averageAll eq 5 }
  45.             <h1>100% poleca ten produkt</h1>
  46.         {/if}
  47.     {/if}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement