Module: Workarea::Storefront::ReviewsHelper

Defined in:
app/helpers/workarea/storefront/reviews_helper.rb

Instance Method Summary collapse

Instance Method Details

#display_purchase_requirement_messageObject



13
14
15
16
17
18
19
# File 'app/helpers/workarea/storefront/reviews_helper.rb', line 13

def display_purchase_requirement_message
  if current_user && Workarea.config.require_purchase_to_post_review && current_user.total_spent.to_f.zero?
    true
  else
    false
  end
end

#rating_stars(rating, options = {}) ⇒ Object



4
5
6
7
8
9
10
11
# File 'app/helpers/workarea/storefront/reviews_helper.rb', line 4

def rating_stars(rating, options = {})
  full_star_count = rating.floor
  empty_star_count = 5 - rating.ceil
  half_star_size = (rating % 1).round(2) * 100
  half_star_width = 20 + (half_star_size - 0) * (80.0 - 20) / (100.0 - 0)

  render 'workarea/storefront/products/rating', rating: rating, full_star_count: full_star_count, empty_star_count: empty_star_count, half_star_width: half_star_width, half_star_size: half_star_size
end