Module: Spree::LoyaltyPoints
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/spree/loyalty_points.rb
Instance Method Summary collapse
- #eligible_for_loyalty_points?(amount) ⇒ Boolean
- #loyalty_points_for(amount, purpose = 'award') ⇒ Object
Instance Method Details
#eligible_for_loyalty_points?(amount) ⇒ Boolean
17 18 19 |
# File 'app/models/concerns/spree/loyalty_points.rb', line 17 def eligible_for_loyalty_points?(amount) amount >= Spree::Store.default.preferred_min_amount_required_to_get_loyalty_points end |
#loyalty_points_for(amount, purpose = 'award') ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'app/models/concerns/spree/loyalty_points.rb', line 7 def loyalty_points_for(amount, purpose = 'award') loyalty_points = if purpose == 'award' && eligible_for_loyalty_points?(amount) (amount * Spree::Store.default.preferred_loyalty_points_awarding_unit).floor elsif purpose == 'redeem' (amount / Spree::Store.default.preferred_loyalty_points_conversion_rate).ceil else 0 end end |