Articles on: Code Snippets

How to add Review List section to your Shopify theme?

If you want to add the review list section to your Shopify website but you have an older theme that does not support app blocks, you need to add the section by editing the code of your theme.

Follow the below steps for adding the earn coins section to your website:

Go to your Shopify admin page

Under Online Store, click on Themes and click on Edit Code in the options



Find the Snippets folder and click on Add a new snippet and write the name nectorcustom_review_list



Copy the below block of code and paste in the file you just created and click on Save

{% assign nector_api_key = shop.metafields.nector.api_key %}
{% assign nector_entity_id = shop.metafields.nector.entity_id %}
{% assign nector_env = shop.metafields.nector.env %}
{% assign nector_is_featured_reviews = is_featured_reviews | default: false %}
{% assign nector_platform_url = 'https://platform.nector.io' %}
{% assign nector_websdk_url = 'https://websdk.nector.io' %}
{% assign nector_script_url = 'https://cdn.nector.io/nector-static/no-cache/reward-widget/mainloader.min.js' %}

{% if customer %}
  {% assign nector_customer_id = customer.id %}
{% endif %}

{% if product and product != empty and product != blank %}
  {% assign nector_product_id = product.id %}
{% endif %}

{% if background_color and background_color != empty and background_color != blank %}
  {% assign nector_background_color = background_color %}
{% endif %}

{% if view_type %}
  {% assign nector_view_type = view_type %}
{% endif %}

{% if default_reviews_sort %}
  {% assign nector_default_reviews_sort = default_reviews_sort %}
{% endif %}

{% if all_reviews %}
  {% assign nector_all_reviews = all_reviews %}
{% endif %}

{% if hide_date %}
  {% assign nector_hide_date = hide_date %}
{% endif %}

{% if show_qna %}
  {% assign nector_show_qna = show_qna %}
{% endif %}

{% if hide_overall_rating %}
  {% assign nector_hide_overall_rating = hide_overall_rating %}
{% endif %}

{% if hide_total_review_count %}
  {% assign nector_hide_total_review_count = hide_total_review_count %}
{% endif %}

{% if nector_env != 'production' %}
  {% assign nector_platform_url = 'https://stageplatform.nector.io' %}
  {% assign nector_websdk_url = 'https://stagewebsdk.nector.io' %}
  {% assign nector_script_url = 'https://cdn.nector.io/nector-static/no-cache/stagereward-widget/mainloader.min.js' %}
{% endif %}

{% if nector_product_id and nector_is_featured_reviews == false %}
  {% assign nector_op = 'review_list' %}
  {% if nector_background_color %}
    <div style="background: {{ nector_background_color }};">
      <script
        async
        src="{{nector_script_url}}"
        data-op="{{nector_op}}"
        data-platform_url="{{nector_platform_url}}"
        data-websdk_url="{{nector_websdk_url}}"
        data-api_key="{{nector_api_key}}"
        data-entity_id="{{nector_entity_id}}"
        data-product_id="{{nector_product_id}}"
        data-platform="shopify"
        {% if nector_default_reviews_sort %}
          data-default_reviews_sort="{{ nector_default_reviews_sort }}"
        {% endif %}
        {% if nector_view_type %}
          data-view_type="{{ nector_view_type }}"
        {% endif %}
        {% if nector_all_reviews %}
          data-all_reviews="true"
        {% endif %}
        {% if nector_hide_date %}
          data-hide_date="true"
        {% endif %}
        {% if nector_show_qna %}
          data-show_qna="true"
        {% endif %}
        {% if nector_hide_overall_rating %}
          data-hide_overall_rating="true"
        {% endif %}
        {% if nector_hide_total_review_count %}
          data-hide_total_review_count="true"
        {% endif %}
      ></script>
    </div>
  {% else %}
    <script
      async
      src="{{nector_script_url}}"
      data-op="{{nector_op}}"
      data-platform_url="{{nector_platform_url}}"
      data-websdk_url="{{nector_websdk_url}}"
      data-api_key="{{nector_api_key}}"
      data-entity_id="{{nector_entity_id}}"
      data-product_id="{{nector_product_id}}"
      data-platform="shopify"
      {% if nector_default_reviews_sort %}
        data-default_reviews_sort="{{ nector_default_reviews_sort }}"
      {% endif %}
      {% if nector_view_type %}
        data-view_type="{{nector_view_type}}"
      {% endif %}
      {% if nector_all_reviews %}
        data-all_reviews="true"
      {% endif %}
      {% if nector_hide_date %}
        data-hide_date="true"
      {% endif %}
      {% if nector_show_qna %}
        data-show_qna="true"
      {% endif %}
      {% if nector_hide_overall_rating %}
        data-hide_overall_rating="true"
      {% endif %}
      {% if nector_hide_total_review_count %}
        data-hide_total_review_count="true"
      {% endif %}
    ></script>
  {% endif %}
{% elsif nector_is_featured_reviews == true %}
  {% if nector_background_color %}
    <div style="background: {{ nector_background_color }};">
      <script
        async
        src="{{nector_script_url}}"
        data-op="featured_review_list"
        data-platform_url="{{nector_platform_url}}"
        data-websdk_url="{{nector_websdk_url}}"
        data-api_key="{{nector_api_key}}"
        data-entity_id="{{nector_entity_id}}"
        data-platform="shopify"
        {% if nector_view_type %}
          data-view_type="{{nector_view_type}}"
        {% endif %}
        {% if nector_show_qna %}
          data-show_qna="true"
        {% endif %}
        {% if nector_hide_overall_rating %}
          data-hide_overall_rating="true"
        {% endif %}
      ></script>
    </div>
  {% else %}
    <script
      async
      src="{{nector_script_url}}"
      data-op="featured_review_list"
      data-platform_url="{{nector_platform_url}}"
      data-websdk_url="{{nector_websdk_url}}"
      data-api_key="{{nector_api_key}}"
      data-entity_id="{{nector_entity_id}}"
      data-platform="shopify"
      {% if nector_hide_title %}
        data-hide_title="true"
      {% endif %}
      {% if nector_hide_overall_rating %}
        data-hide_overall_rating="true"
      {% endif %}
    ></script>
  {% endif %}
{% endif %}




After that, find the file that has the code related to your product page, and paste the below line of code wherever appropriate based on where you want to display the section

Since each theme will have different files and structure, it is not possible to mention the exact file in which you have to put the below line of code. You need to find the appropriate file for your current theme and paste it in there.

Use the below line for adding the normal reviews:

{% render 'nectorcustom_review_list', product: product, customer: customer, shop: shop %}


Use the below line for adding the featured reviews:

{% render 'nectorcustom_review_list', product: product, customer: customer, shop: shop, is_featured_reviews: true %}


Click on Save button

After adding the line of code for normal reviews, the reviews section will be visible on your page












Review FAQs

Updated on: 17/07/2024

Was this article helpful?

Share your feedback

Cancel

Thank you!