Sha256: c36f84e5d04b32ce5d9806f4e8649abba649dbe6134536f58a745b5c8b5cd24f
Contents?: true
Size: 661 Bytes
Versions: 34
Compression:
Stored size: 661 Bytes
Contents
# frozen_string_literal: true module Spree class Promotion < Spree::Base module Rules class OneUsePerUser < PromotionRule def applicable?(promotable) promotable.is_a?(Spree::Order) end def eligible?(order, _options = {}) if order.user.present? if promotion.used_by?(order.user, [order]) eligibility_errors.add(:base, eligibility_error_message(:limit_once_per_user)) end else eligibility_errors.add(:base, eligibility_error_message(:no_user_specified)) end eligibility_errors.empty? end end end end end
Version data entries
34 entries across 34 versions & 2 rubygems