Sha256: 389cbc29d24406dcd65e132eb3199febcb74c46accbe5fdce671f4c2409bac79
Contents?: true
Size: 956 Bytes
Versions: 7
Compression:
Stored size: 956 Bytes
Contents
class Plugins::Ecommerce::Coupon < CamaleonCms::TermTaxonomy default_scope { where(taxonomy: :ecommerce_coupon) } belongs_to :site, :class_name => "CamaleonCms::Site", foreign_key: :parent_id scope :actives, -> {where(status: '1')} def used_times_exceeded? (used_applications + 1) > allowed_applications end def mark_as_used(user = nil) set_option('used_applications', used_applications + 1) end def used_applications get_option('used_applications', 0).to_i end def allowed_applications get_option('allowed_applications', 0).to_i end def expired? d = get_option('expirate_date', '') if d.present? "#{d} 23:59:59".to_datetime.to_i < Time.current.to_i else false end end def min_cart_total get_option('min_cart_total', '') end def valid_min_price?(price) !min_cart_total.present? || min_cart_total.to_i <= price end def active? status.to_s == '1' end end
Version data entries
7 entries across 7 versions & 1 rubygems