Sha256: 2ac3fd110ffd4c1bce2b916bd56dafe72b6d94cb98643e4c53a613a5ed7cf2d5
Contents?: true
Size: 772 Bytes
Versions: 4
Compression:
Stored size: 772 Bytes
Contents
# frozen_string_literal: true module SolidusFriendlyPromotions module Conditions class OptionValue < Condition include LineItemApplicableOrderCondition preference :eligible_values, :hash def order_eligible?(order) order.line_items.any? { |item| line_item_eligible?(item) } end def line_item_eligible?(line_item) LineItemOptionValue.new(preferred_eligible_values: preferred_eligible_values).eligible?(line_item) end def preferred_eligible_values values = preferences[:eligible_values] || {} values.keys.map(&:to_i).zip( values.values.map do |value| (value.is_a?(Array) ? value : value.split(",")).map(&:to_i) end ).to_h end end end end
Version data entries
4 entries across 4 versions & 1 rubygems