contains_set
Last updated
{% comment %} Fetch all existing SKUs from Shopify {% endcomment %}
{% assign all_skus = "[]" | parse %}
{% for n in (0..100) %}
{% graphql query: sku_query, variables: vars as result %}
{% for edge in result.productVariants.edges %}
{% assign all_skus = all_skus | push: edge.node.sku %}
{% endfor %}
{% unless result.productVariants.pageInfo.hasNextPage %}{% break %}{% endunless %}
{% endfor %}
{% comment %} Check each import row against existing SKUs {% endcomment %}
{% for row in import_data %}
{% if all_skus | contains_set: row.sku %}
{% log "SKU already exists: " | append: row.sku %}
{% else %}
{% comment %} Create new product {% endcomment %}
{% endif %}
{% endfor %}{% assign excluded_tags = "sale,clearance,discontinued" | split: "," %}
{% assign products_to_process = "[]" | parse %}
{% for product in all_products %}
{% assign dominated_value = false %}
{% for tag in product.tags %}
{% if excluded_tags | contains_set: tag %}
{% assign dominated_value = true %}
{% break %}
{% endif %}
{% endfor %}
{% unless dominated_value %}
{% assign products_to_process = products_to_process | push: product %}
{% endunless %}
{% endfor %}{% assign allowed_product_ids = allowed_products | map: "id" %}
{% for line_item in order.line_items %}
{% unless allowed_product_ids | contains_set: line_item.product_id %}
{% log "Unauthorized product in order: " | append: line_item.title %}
{% assign has_unauthorized = true %}
{% endunless %}
{% endfor %}