The source code of the files

I. snippets/a2reviews-widget.liquid

Main widget: Use to display a list of product reviews or feature reviews. This code can only be used to display a single product, or to display on the “Happy customer” page. You can also display the feature product on the homepage.

{% assign A2MetaProduct = product.metafields.a2reviews %}
<div class="container page-width a2reviews-container">
{% if type == 'QA' %}
    {% if shop.metafields.a2reviews.qa_status != 0 %}
    <a2-questions
      lang="{{ shop.locale }}"
      handle="{{ product.handle }}">
    </a2-questions>
    {% endif %}
{% else %}
    <a2-reviews
        handle="{{ product.handle }}"
        lang="{{ shop.locale }}">
    </a2-reviews>
{% endif %}
</div>
<div style="width:100%;height:40px;clear:both;"></div>
{% if template contains 'product' and type != 'QA' %}
{%- assign a2_current_variant = product.selected_or_first_available_variant -%}
{%- if cart.currency.iso_code == 'GBP' or cart.currency.iso_code == 'USD' or cart.currency.iso_code == 'AUD' or cart.currency.iso_code == 'AED' or cart.currency.iso_code == 'CAD' or cart.currency.iso_code == 'BWP' or cart.currency.iso_code == 'BND' or cart.currency.iso_code == 'DOP' or cart.currency.iso_code == 'GTQ' or cart.currency.iso_code == 'HKD' or cart.currency.iso_code == 'INR' or cart.currency.iso_code == 'ILS' or cart.currency.iso_code == 'YEN' or cart.currency.iso_code == 'KES' or cart.currency.iso_code == 'KOR' or cart.currency.iso_code == 'LBP' or cart.currency.iso_code == 'MYR' or cart.currency.iso_code == 'MXN' or cart.currency.iso_code == 'NPR' or cart.currency.iso_code == 'NZD' or cart.currency.iso_code == 'NIO' or cart.currency.iso_code == 'NGN' or cart.currency.iso_code == 'PKR' or cart.currency.iso_code == 'CNY' or cart.currency.iso_code == 'PHP' or cart.currency.iso_code == 'SGD' or cart.currency.iso_code == 'LKR' or cart.currency.iso_code == 'CHF' or cart.currency.iso_code == 'TWD' or cart.currency.iso_code == 'TSH' or cart.currency.iso_code == 'THB' or cart.currency.iso_code == 'UGX' or cart.currency.iso_code == 'KWD' or cart.currency.iso_code == 'CLP' -%}
{%- assign a2_product_price = a2_current_variant.price | money_without_currency | remove:',' -%}
{%- else -%}
{%- assign a2_product_price = a2_current_variant.price | money_without_currency | remove:'.' | replace: ',', '.' -%}
{%- endif -%}
<script type="application/ld+json">
    {
      "@context": "https://schema.org/",
      "@type": "Product",
      "brand": {
        "@type": "Brand",
      "name": "{{ product.vendor | escape }}"
      },
      "description": "{{ product.description | strip_html | truncatewords: 50 }}",
      "sku": "{{ a2_current_variant.sku }}",
      "mpn": "{{ a2_current_variant.barcode }}",
      "image": "https:{{ product.featured_image.src | img_url: 'grande' }}",
      "name": "{{ product.title }}",
      "review": [{% for review in A2_Reviews limit:2 %}{
        "@type": "Review",
        "reviewRating": {
          "@type": "Rating",
          "ratingValue": "{{ review.rating }}"
        },
        "author": {
          "@type": "Person",
          "name": "{{ review.author }}"
        },
        "reviewBody": "{{ review.content }}"
      }{% if forloop.last != true %},{% endif %}{% endfor %}],
      {%- if A2MetaProduct.total_rating > 0 -%}
      "aggregateRating": {
        "@type": "AggregateRating",
        "ratingValue": "{{ A2MetaProduct.avg_rating }}",
        "bestRating": "5",
        "ratingCount": "{{ A2MetaProduct.total_rating }}"
      },
      {% endif %}
      "offers": {
        "@type": "Offer",
        "url": "{{ shop.url }}{{ a2_current_variant.url }}",
        "priceCurrency": "{{ cart.currency.iso_code }}",
        "price": "{{ a2_product_price }}",
        "priceValidUntil": "{{ 'now' | date: '%s' | plus: 31536000 | date: '%Y-%m-%d' | uri_encode | replace:'+','%20' }}",
        "itemCondition": "https://schema.org/UsedCondition",
        "availability": "http://schema.org/{% if a2_current_variant.available %}InStock{% else %}OutOfStock{% endif %}",
        "seller": {
          "@type": "Organization",
          "name": "Shopify"
        }
      }
    }
</script>
{% endif %}

2. snippets/a2reviews-total.liquid

Total widget: This is a widget to display the total number of reviews for a product, it can be used on the product page or in a loop of products in a collection.

3. snippets/a2reviews-head-var.liquid

Global Configuration: This is the file that will contain the store's configuration content in the A2Reviews application. It's built to build a global variable for JavaScript.

4. sections/a2reviews-main-widget.liquid

Customize Block: This is a configuration file so you can drag and drop Section in Customize theme mode in Shopify admin. This block only appears on the product page.

5. sections/a2reviews-block.liquid

Customize Block: This is a configuration file so you can drag and drop Section in Customize theme mode in Shopify admin. This block is used on all pages. You need to create Block in A2Reviews app, then use ID to fill in the required field.

Last updated