Personalized checkout and custom promotions with Shopify Scripts
I'm noticing that there are changes being made to scripts that are posted. This causes errors in the script and makes it harder for Shopify Partners to help merchants.
EXAMPLE
@tags = tags.map { |tag| tag.downcase.strip } is changed to @Tags = tags.map { |tag| tag.downcase.strip }
@selector_type = selector_type is changed to @Selector_type = selector_type
I am testing this script (http://www.kaliara.com/test-script.rb) here... which seems to work
# ================================================================
# CustomerTagSelector
#
# Finds whether the supplied customer has any of the entered tags.
# ================================================================
class CustomerTagSelector
def initialize(match_type, tags)
@comparator = match_type == :include ? 'any?' : 'none?'
@tags = tags.map { |tag| tag.downcase.strip }
end
def match?(customer)
customer_tags = customer.tags.map { |tag| tag.downcase.strip }
(@tags & customer_tags).send(@comparator)
end
end
# ================================================================
# ProductSelector
#
# Finds matching products by the entered criteria.
# ================================================================
class ProductSelector
def initialize(match_type, selector_type, selectors)
@match_type = match_type
@comparator = match_type == :include ? 'any?' : 'none?'
@selector_type = selector_type
@selectors = selectors
end
def match?(line_item)
if self.respond_to?(@selector_type)
self.send(@selector_type, line_item)
else
raise RuntimeError.new('Invalid product selector type')
end
end
end
POSSIBLE CAUSES
I think the forum is trying to turn those into "at mentions" and is picking out a few words (like tag and selector) because they must match some user or something.
Any help from @Jason or Shopify would be great!
Thanks,
Matthew
Doesn't seem to be happening in the post above, but it occurred multiple times in this post: https://community.shopify.com/c/Script-Editor/Shipping-Script-to-hide-shipping-options-based-on-prod...
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024