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

Inherits:
Spree::PromotionRule show all
Defined in:
core/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

Instance Method Details

#applicable?(promotable) ⇒ Boolean

This promotion is applicable to orders only.

Returns:

  • (Boolean)


13
14
15
# File 'core/app/models/spree/promotion/rules/nth_order.rb', line 13

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

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

This is never eligible if the order does not have a user, and that user does not have any previous completed orders.

Use the first order rule if you want a promotion to be applied to the first order for a user.

Parameters:

Returns:

  • (Boolean)


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

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

  nth_order?(order)
end