Ruby scripts added to posts are getting altered

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

Playwright | Create Shopify Scripts without writing code | https://playwrightapp.com
- Was my reply helpful? Please Like and Accept Solution.
- Need help with a custom Shopify script? Email me at matthew@playwrightapp.com

0 Likes

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...

Playwright | Create Shopify Scripts without writing code | https://playwrightapp.com
- Was my reply helpful? Please Like and Accept Solution.
- Need help with a custom Shopify script? Email me at matthew@playwrightapp.com

0 Likes