Autocomplete Search Available product display

Tourist
27 0 2

In search autocomplete functionality...it doesn't seem the json is allowing interruption by product.available:

The code below returns all results on the actual search landing page, and an empty display even on search terms that should yield some result.  I have attempted including another if conditional for object_type, but same results.

{% capture results %}
  {% for item in search.results %}
    {% if item.available %}
	{% assign product = item %}
    { 
      "title"    : {{ product.title | json }},
      "url"      : {{ product.url | within: product.collections.last | json }},
      "thumbnail": {{ product.featured_image.src | product_img_url: 'thumb' | json }}
    }
    {% unless forloop.last %},{% endunless %}
    {% endif %}
  {% endfor %}
{% endcapture %}
{
  "results_count": {{ search.results_count }},
  "results": [{{ results }}]
}

Am I missing something formatting related, or is it not possible to interact with json files this way?

0 Likes