Module: Spree::ReviewsHelper
- Defined in:
- app/helpers/spree/reviews_helper.rb
Instance Method Summary collapse
- #display_verified_purchaser?(review) ⇒ Boolean
- #mk_stars(m) ⇒ Object
- #star(the_class) ⇒ Object
- #txt_stars(n, show_out_of = true) ⇒ Object
Instance Method Details
#display_verified_purchaser?(review) ⇒ Boolean
18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/spree/reviews_helper.rb', line 18 def display_verified_purchaser?(review) Spree::Reviews::Config[:show_verified_purchaser] && review.user && Spree::LineItem.joins(:order, :variant) .where.not(spree_orders: { completed_at: nil }) .find_by( spree_variants: { product_id: review.product_id }, spree_orders: { user_id: review.user_id } ).present? end |
#mk_stars(m) ⇒ Object
8 9 10 |
# File 'app/helpers/spree/reviews_helper.rb', line 8 def mk_stars(m) (1..5).collect { |n| n <= m ? star("lit") : star("unlit") }.join end |
#star(the_class) ⇒ Object
4 5 6 |
# File 'app/helpers/spree/reviews_helper.rb', line 4 def star(the_class) tag.span(" ✮ ".html_safe, class: the_class) end |
#txt_stars(n, show_out_of = true) ⇒ Object
12 13 14 15 16 |
# File 'app/helpers/spree/reviews_helper.rb', line 12 def txt_stars(n, show_out_of = true) res = I18n.t('spree.star', count: n) res += " #{I18n.t('spree.out_of_5')}" if show_out_of res end |