Class: Spree::PromotionCode
- Defined in:
- app/models/spree/promotion_code.rb
Defined Under Namespace
Classes: CodeBuilder
Instance Method Summary collapse
-
#usage_count ⇒ Integer
Number of times the code has been used overall.
- #usage_limit ⇒ Object
-
#usage_limit_exceeded? ⇒ Boolean
Whether the promotion code has exceeded its usage restrictions.
Methods inherited from Base
display_includes, #initialize_preference_defaults, page, preference
Methods included from Spree::Preferences::Preferable
#default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference
Instance Method Details
#usage_count ⇒ Integer
Number of times the code has been used overall
24 25 26 27 28 29 30 |
# File 'app/models/spree/promotion_code.rb', line 24 def usage_count adjustments.eligible. joins(:order). merge(Spree::Order.complete). distinct. count(:order_id) end |
#usage_limit ⇒ Object
32 33 34 |
# File 'app/models/spree/promotion_code.rb', line 32 def usage_limit promotion.per_code_usage_limit end |
#usage_limit_exceeded? ⇒ Boolean
Whether the promotion code has exceeded its usage restrictions
15 16 17 18 19 |
# File 'app/models/spree/promotion_code.rb', line 15 def usage_limit_exceeded? if usage_limit usage_count >= usage_limit end end |