Created
October 8, 2019 12:11
-
-
Save loughlincodes/0f98ace464acd1f47cd887b5c7c31158 to your computer and use it in GitHub Desktop.
Shopify Loox Reviews - get total reviews
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="reviews"> | |
{% assign looxstats = shop.metafields.loox["global_stats"] | split: "," %} | |
{% assign looxstar = looxstats[0] | round %} | |
{% assign looxcount = looxstats[1] | times:100 | money_without_currency | remove: '.00' %} | |
<a href="pages/happy-customers">Reviews (<span class="looxstars">{% for i in (1..looxstar) %}★{% endfor %}</span> {{ looxcount }})</a> | |
</div> <!-- end review --> |
Ah, I see, so I have to give it a access permission using admin api. Thanks a lot!
No probs! Best of luck 🤞
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah, as the metafield is created by the Loox app it must be setting the metafield to private on creation which means it can't be accessed via the storefront API directly.
In a store that has Loox installed, you can see the product level metafields in the admin and these are defaulted to being hidden from the storefront API:
You may be able to edit the shop.metafields.loox.global_stats storefront API visibility using this GraphQL mutation:
https://shopify.dev/docs/api/admin-graphql/2023-10/objects/metafieldstorefrontvisibility
As a last straw, you could contact Loox support - I have found them to be very responsive and interested in use-cases they hadn't considered before. They might be able to set that loox.global_stats to be accessible via the storefront API for you. Worth a shot if the above doesn't help.