Class: SolidusFriendlyPromotions::Conditions::FirstOrder
- Inherits:
-
SolidusFriendlyPromotions::Condition
- Object
- Spree::Base
- SolidusFriendlyPromotions::Condition
- SolidusFriendlyPromotions::Conditions::FirstOrder
- Includes:
- OrderLevelCondition
- Defined in:
- app/models/solidus_friendly_promotions/conditions/first_order.rb
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
Methods included from OrderLevelCondition
Methods inherited from SolidusFriendlyPromotions::Condition
#applicable?, #eligibility_errors, #level, #preload_relations, #to_partial_path, #updateable?
Instance Attribute Details
#email ⇒ Object (readonly)
Returns the value of attribute email.
7 8 9 |
# File 'app/models/solidus_friendly_promotions/conditions/first_order.rb', line 7 def email @email end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
7 8 9 |
# File 'app/models/solidus_friendly_promotions/conditions/first_order.rb', line 7 def user @user end |
Instance Method Details
#eligible?(order, options = {}) ⇒ Boolean
9 10 11 12 13 14 15 16 17 18 |
# File 'app/models/solidus_friendly_promotions/conditions/first_order.rb', line 9 def eligible?(order, = {}) @user = order.try(:user) || [:user] @email = order.email if (user || email) && (completed_orders.present? && completed_orders.first != order) eligibility_errors.add(:base, (:not_first_order), error_code: :not_first_order) end eligibility_errors.empty? end |