Hello, Can Someone please help me to resolve the error?
here is the link from where I am copying the script.
that is the script I am adding.
# ================================ Customizable Settings ================================
# ================================================================
# Hide Rate(s) for Zip/Province/Country
#
# If the cart's shipping address country/province/zip match the
# entered settings, the entered rate(s) are hidden.
#
# - 'country_code' is a 2-character abbreviation for the
# applicable country or region
# - 'province_code' is a list of 2-character abbreviations for
# the applicable provinces or states
# - 'zip_code_match_type' determines whether the below strings
# should be an exact or partial match. Can be:
# - ':exact' for an exact match
# - ':partial' for a partial match
# - 'zip_codes' is a list of strings to identify zip codes
# - 'rate_match_type' determines whether the below strings
# should be an exact or partial match. Can be:
# - ':exact' for an exact match
# - ':partial' for a partial match
# - ':all' for all rates
# - 'rate_names' is a list of strings to identify rates
# - if using ':all' above, this can be set to 'nil'
# ================================================================
HIDE_RATES_FOR_ZIP_PROVINCE_COUNTRY = [
{
country_code: "US",
province_code: "CA",
zip_code_match_type: :exact,
zip_codes: ["90210"],
rate_match_type: :exact,
rate_names: ["Shipping Rate"],
},
]
# ================================ Script Code (do not edit) ================================
# ================================================================
# ZipCodeSelector
#
# Finds whether the supplied zip code matches any of the entered
# strings.
# ================================================================
class ZipCodeSelector
def initialize(match_type, zip_codes)
@comparator = match_type == :exact ? '==' : 'include?'
@zip_codes = zip_codes.map { |zip_code| zip_code.upcase.strip }
end
def match?(zip_code)
@zip_codes.any? { |zip| zip_code.to_s.upcase.strip.send(@comparator, zip) }
end
end
# ================================================================
# RateNameSelector
#
# Finds whether the supplied rate name matches any of the entered
# names.
# ================================================================
class RateNameSelector
def initialize(match_type, rate_names)
@match_type = match_type
@comparator = match_type == :exact ? '==' : 'include?'
@rate_names = rate_names&.map { |rate_name| rate_name.downcase.strip }
end
def match?(shipping_rate)
if @match_type == :all
true
else
@rate_names.any? { |name| shipping_rate.name.downcase.send(@comparator, name) }
end
end
end
# ================================================================
# HideRatesForZipProvinceCountryCampaign
#
# If the cart's shipping address zip/province/country match the
# entered settings, the entered rate(s) are hidden.
# ================================================================
class HideRatesForZipProvinceCountryCampaign
def initialize(campaigns)
@campaigns = campaigns
end
def run(cart, shipping_rates)
address = cart.shipping_address
return if address.nil?
@campaigns.each do |campaign|
zip_code_selector = ZipCodeSelector.new(campaign[:zip_code_match_type], campaign[:zip_codes])
country_match = address.country_code.upcase.strip == campaign[:country_code].upcase.strip
province_match = address.province_code.upcase.strip == campaign[:province_code].upcase.strip
zip_match = zip_code_selector.match?(address.zip)
next unless country_match && province_match && zip_match
rate_name_selector = RateNameSelector.new(campaign[:rate_match_type], campaign[:rate_names])
shipping_rates.delete_if do |shipping_rate|
rate_name_selector.match?(shipping_rate)
end
end
end
end
CAMPAIGNS = [
HideRatesForZipProvinceCountryCampaign.new(HIDE_RATES_FOR_ZIP_PROVINCE_COUNTRY),
]
CAMPAIGNS.each do |campaign|
campaign.run(Input.cart, Input.shipping_rates)
end
Output.shipping_rates = Input.shipping_rates
**I have follow the step by step instruction**
**I am attaching screen shot below that is showing error.**
<strong>

</strong>