Class: CouponFirstPurchaseValue

Inherits:
CouponValue show all
Defined in:
app/models/coupon_first_purchase_value.rb

Constant Summary

Constant Summary

Constants inherited from Coupon

Coupon::COUPON_TYPES

Instance Attribute Summary

Attributes inherited from Coupon

#c_type

Instance Method Summary (collapse)

Methods inherited from Coupon

#display_expires_time, #display_start_time, #qualified?, #value

Instance Method Details

- (Boolean) eligible?(order, at = nil)

Returns:

  • (Boolean)


2
3
4
5
# File 'app/models/coupon_first_purchase_value.rb', line 2

def eligible?(order, at = nil )
  at ||= order.completed_at || Time.zone.now
  (starts_at <= at && expires_at >= at) && (order.user.try(:number_of_finished_orders_at, at) == 0) rescue false
end