Class: Spree::Promotion::Rules::NthOrder

Inherits:
Spree::PromotionRule show all
Defined in:
app/models/spree/promotion/rules/nth_order.rb

Instance Method Summary collapse

Methods inherited from Spree::PromotionRule

#actionable?, #eligibility_errors, for, #to_partial_path

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

#applicable?(promotable) ⇒ Boolean

This promotion is applicable to orders only.

Returns:

  • (Boolean)


11
12
13
# File 'app/models/spree/promotion/rules/nth_order.rb', line 11

def applicable?(promotable)
  promotable.is_a?(Spree::Order)
end

#eligible?(order, _options = {}) ⇒ Object



20
21
22
23
24
# File 'app/models/spree/promotion/rules/nth_order.rb', line 20

def eligible?(order, _options = {})
  return false unless order.user

  nth_order?(order)
end