Add search file to enable the Quote function in the front store

In order to get the Quote function of SA Request a Quote app to work in your theme, you need to manually add a search file for the app to enable the app data in your theme. Kindly review this document

  1. From the Shopify admin page, choose the Online Store folder > Themes

  2. In Themes > choose the More actions button > Edit code

3. On the code page, click on “Add a new template” > choose Template type: search > liquid > Fill in the file name as: rfq

4. Set Done.

5. Add the below codes to the file:

{%- layout none -%}
{%- if search.terms contains 'handles:' -%}
[
  {%- assign params = canonical_url | url_decode | split: "?" | last | split: "&" -%}
  {%- assign handles = '' -%}
  {%- for str in params -%}
    {%- assign str_split = str | split: "=" -%}
    {%- if str_split.first == 'q' -%}
      {%- assign handles = str_split.last | remove_first: "handles:" -%}
    {%- endif -%}
  {%- endfor -%}
  {%- if handles != '' -%}
    {%- assign handles = handles | split: "|" -%}
    {%- for handle in handles limit:20 -%}
      {%- assign product = all_products[handle] -%}
      {%- unless forloop.first -%},{%- endunless -%}
      {%- if product.id != '' -%}
        {
          "available": {{product.available}},
          "id": {{ product.id }},
          "handle": "{{ product.handle }}",
          "options": {{ product.options | json }},
          "variants": {{ product.variants | json }},
          "price": {{ product.price }},
          "tags": {{ product.tags | json }},
          "title": {{ product.title | json }},
          "type": {{ product.type | json }},
          "url": "{{ product.url }}",
          "vendor": {{ product.vendor | json }},
          "featured_image": "{{ product.featured_image.src | image_url }}",
          "images": {{ product.images | json }},
          "collection": {{ product.collections | map: 'id' | json }}
        }
      {%- else -%}
        null
      {%- endif -%}
    {%- endfor -%}
  {%- endif -%}
]
{%- else -%}
[
  {%- assign q = search.terms | downcase -%}
  {%- assign first = true -%}
  {%- for product in search.results -%}
    {%- assign matched = false -%}
    {%- assign title = product.title | downcase -%}

    {%- if title contains q -%}
      {%- assign matched = true -%}
    {%- endif -%}

    {%- for variant in product.variants -%}
      {%- assign sku = variant.sku | downcase -%}
      {%- if sku contains q -%}
        {%- assign matched = true -%}
      {%- endif -%}
    {%- endfor -%}

    {%- if matched -%}
      {%- unless first -%},{%- endunless -%}
      {%- assign first = false -%}
      {
        "available": {{product.available}},
        "id": {{ product.id }},
        "handle": "{{ product.handle }}",
        "options": {{ product.options | json }},
        "variants": {{ product.variants | json }},
        "price": {{ product.price }},
        "tags": {{ product.tags | json }},
        "title": {{ product.title | json }},
        "type": {{ product.type | json }},
        "url": "{{ product.url }}",
        "vendor": {{ product.vendor | json }},
        "featured_image": "{{ product.featured_image.src | image_url }}",
        "images": {{ product.images | json }},
        "collection": {{ product.collections | map: 'id' | json }}
      }
    {%- endif -%}
  {%- endfor -%}
]
{%- endif -%}

6. Click Save to finish creating this new file.

Last updated

Was this helpful?