Class: Spree::PromotionCode
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- 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.
Instance Method Details
#usage_count ⇒ Integer
Number of times the code has been used overall
22 23 24 25 26 27 28 |
# File 'app/models/spree/promotion_code.rb', line 22 def usage_count adjustments.eligible. joins(:order). merge(Spree::Order.complete). distinct. count(:order_id) end |
#usage_limit ⇒ Object
30 31 32 |
# File 'app/models/spree/promotion_code.rb', line 30 def usage_limit promotion.per_code_usage_limit end |
#usage_limit_exceeded? ⇒ Boolean
Whether the promotion code has exceeded its usage restrictions
13 14 15 16 17 |
# File 'app/models/spree/promotion_code.rb', line 13 def usage_limit_exceeded? if usage_limit usage_count >= usage_limit end end |