Skip to content

Commit

Permalink
Merge pull request #78 from jgodson/add-variant-title-selector
Browse files Browse the repository at this point in the history
add variant title selector
  • Loading branch information
jgodson authored Jan 29, 2023
2 parents 927adf8 + 7a1d8fa commit 82ac1d8
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ruby_scripts/common/variant_title_selector.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class VariantTitleSelector < Selector
def initialize(match_type, variant_titles)
@invert = match_type == :not_one
@variant_titles = variant_titles.map { |title| title.downcase }
end

def match?(line_item)
@invert ^ @variant_titles.include?(line_item.variant.title.downcase)
end
end

36 changes: 36 additions & 0 deletions src/scripts/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,18 @@ class VariantSkuSelector < Selector
end
end`,

VariantTitleSelector: `
class VariantTitleSelector < Selector
def initialize(match_type, variant_titles)
@invert = match_type == :not_one
@variant_titles = variant_titles.map { |title| title.downcase }
end
def match?(line_item)
@invert ^ @variant_titles.include?(line_item.variant.title.downcase)
end
end`,

ZipCodeQualifier: `
class ZipCodeQualifier < Qualifier
def initialize(match_type, match_condition, zips)
Expand Down Expand Up @@ -1048,6 +1060,30 @@ const lineItemSelectors = [{
}
}
},
{
value: "VariantTitleSelector",
label: "Variant Title",
description: "Selects line items by the title of the variant",
inputs: {
match_condition: {
type: "select",
description: "Set how variant titles are matched",
options: [{
value: "is_one",
label: "Is one of"
},
{
value: "not_one",
label: "Is not one of"
}
]
},
variant_Titles: {
type: "array",
description: "Enter the applicable titles"
}
}
},
{
value: "LineItemPropertiesSelector",
label: "Has Properties",
Expand Down

0 comments on commit 82ac1d8

Please sign in to comment.