Class: SolidusFriendlyPromotions::Conditions::LineItemOptionValue
Instance Method Summary
collapse
#applicable?, #level
#applicable?, #eligibility_errors, #level, #preload_relations, #to_partial_path, #updateable?
Instance Method Details
#eligible?(line_item, _options = {}) ⇒ Boolean
10
11
12
13
14
15
|
# File 'app/models/solidus_friendly_promotions/conditions/line_item_option_value.rb', line 10
def eligible?(line_item, _options = {})
pid = line_item.product.id
ovids = line_item.variant.option_values.pluck(:id)
product_ids.include?(pid) && (value_ids(pid) & ovids).present?
end
|
#preferred_eligible_values ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'app/models/solidus_friendly_promotions/conditions/line_item_option_value.rb', line 17
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
|