Sha256: 9f353d4edf20de719ce44c079a551da116c220c3a958df20c7b7daa0c434ff0a

Contents?: true

Size: 1005 Bytes

Versions: 3

Compression:

Stored size: 1005 Bytes

Contents

module Workarea
  module Storefront
    module ReviewsHelper
      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)
        itemprop = options[:aggregate] ? 'aggregateRating' : 'reviewRating'
        itemtype = options[:aggregate] ? 'http://schema.org/AggregateRating' : 'http://schema.org/Rating'

        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, itemprop: itemprop, itemtype: itemtype
      end

      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
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workarea-reviews-3.0.10 app/helpers/workarea/storefront/reviews_helper.rb
workarea-reviews-3.0.9 app/helpers/workarea/storefront/reviews_helper.rb
workarea-reviews-3.0.8 app/helpers/workarea/storefront/reviews_helper.rb