Sha256: cdb544d1abf057986337779e7f2c0f466416bed190122dc111a09c758b0a6b8f
Contents?: true
Size: 659 Bytes
Versions: 19
Compression:
Stored size: 659 Bytes
Contents
module Spree class Promotion module Rules class FirstOrder < PromotionRule attr_reader :user, :email 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 private def completed_orders user ? user.orders.complete : orders_by_email end def orders_by_email Spree::Order.where(:email => email).complete end end end end end
Version data entries
19 entries across 19 versions & 2 rubygems