Class: Spree::Promotion::Rules::FirstOrder

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email


5
6
7
# File 'app/models/spree/promotion/rules/first_order.rb', line 5

def email
  @email
end

#userObject (readonly)

Returns the value of attribute user


5
6
7
# File 'app/models/spree/promotion/rules/first_order.rb', line 5

def user
  @user
end

Instance Method Details

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


7
8
9
10
11
12
13
14
15
16
# File 'app/models/spree/promotion/rules/first_order.rb', line 7

def eligible?(order, options = {})
  @user = order.try(:user) || options[:user]
  @email = order.email

  if user || email
    completed_orders.blank? || (completed_orders.first == order)
  else
    false
  end
end