Class: Spree::PromotionCode
- Defined in:
- app/models/spree/promotion_code.rb
Defined Under Namespace
Classes: BatchBuilder
Instance Method Summary collapse
-
#usage_count(excluded_orders: []) ⇒ Integer
Number of times the code has been used overall.
- #usage_limit ⇒ Object
-
#usage_limit_exceeded?(excluded_orders: []) ⇒ 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
#admin_form_preference_names, #default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference
Instance Method Details
#usage_count(excluded_orders: []) ⇒ Integer
Number of times the code has been used overall
29 30 31 32 33 34 |
# File 'app/models/spree/promotion_code.rb', line 29 def usage_count(excluded_orders: []) adjustments. eligible. in_completed_orders(excluded_orders: excluded_orders). count(:order_id) end |
#usage_limit ⇒ Object
36 37 38 |
# File 'app/models/spree/promotion_code.rb', line 36 def usage_limit promotion.per_code_usage_limit end |
#usage_limit_exceeded?(excluded_orders: []) ⇒ Boolean
Whether the promotion code has exceeded its usage restrictions
19 20 21 22 23 |
# File 'app/models/spree/promotion_code.rb', line 19 def usage_limit_exceeded?(excluded_orders: []) if usage_limit usage_count(excluded_orders: excluded_orders) >= usage_limit end end |