Class: Spree::Promotion::Rules::FirstRepeatPurchaseSince Private

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

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary (collapse)

Methods inherited from Spree::PromotionRule

#actionable?, #eligibility_errors, for

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

- (Boolean) applicable?(promotable)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This promotion is applicable to orders only.

Returns:

  • (Boolean)


9
10
11
# File 'app/models/spree/promotion/rules/first_repeat_purchase_since.rb', line 9

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

- (Object) eligible?(order, _options = {})



18
19
20
21
22
23
24
25
# File 'app/models/spree/promotion/rules/first_repeat_purchase_since.rb', line 18

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

  last_order = last_completed_order(order.user)
  return false unless last_order

  last_order.completed_at < preferred_days_ago.days.ago
end