Sha256: e88a64c82000f416a5e15e2a8d4c6a7660cf7881116cdb19130c4378ddf4e14b
Contents?: true
Size: 727 Bytes
Versions: 99
Compression:
Stored size: 727 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), error_code: :limit_once_per_user) end else eligibility_errors.add(:base, eligibility_error_message(:no_user_specified), error_code: :no_user_specified) end eligibility_errors.empty? end end end end end
Version data entries
99 entries across 99 versions & 2 rubygems