Class: Spree::TaxonRules::AvailableOn
- Inherits:
-
Spree::TaxonRule
- Object
- Spree::TaxonRule
- Spree::TaxonRules::AvailableOn
- Defined in:
- app/models/spree/taxon_rules/available_on.rb
Constant Summary
Constants inherited from Spree::TaxonRule
Spree::TaxonRule::MATCH_POLICIES
Instance Method Summary collapse
Instance Method Details
#apply(scope) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/models/spree/taxon_rules/available_on.rb', line 4 def apply(scope) # value here is no of weeks # eg. return products that become available in the last 2 weeks timezone = taxon.store.preferred_timezone date = value.to_i.days.ago.beginning_of_day.in_time_zone(timezone) if match_policy == 'is_equal_to' scope.where(['spree_products.created_at >= ?', date]).or( scope.where(['spree_products.available_on >= ?', date]) ) else scope end end |