savchukoleksii
6/3/2019 - 8:17 AM

Shopify Replace Unlisted Symbolds

{% comment %}
  Replace all symbols that not listed in `except_symbols`
{% endcomment %}

{%- assign separator = '%%%' -%}
{%- assign except_symbols = '1234567890.' -%}
{%- assign international_shipping = settings.international_shipping -%}
{%- assign international_shipping_except = except_symbolds | split: '' | uniq | join: separator -%}
{%- assign international_shipping_except = international_shipping_except | split: separator -%}
{%- assign international_shipping_array = settings.international_shipping | split: "" | uniq -%}

{%- for international_shipping_element in international_shipping_array -%}
    {%- unless international_shipping_except contains international_shipping_element -%}
        {%- assign international_shipping = international_shipping | replace: international_shipping_element, '' -%}
    {%- endunless -%}
{%- endfor -%}

{{- international_shipping -}}