-
-
Save loughlincodes/0f98ace464acd1f47cd887b5c7c31158 to your computer and use it in GitHub Desktop.
<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 --> |
Where can I find all shop metafields in admin? I am working on a hydrogen project and wondering if that metafield still exists in this case..
@supermaxholloway I don't think there is a way to view all Shop metafields in the admin (not that I know of anyway). I normally use GraphQL to retrieve a list of shop level metafields from within my app:
{
shop {
metafields(first: 100) {
edges {
node {
id
namespace
key
value
description
}
}
}
}
}
and then work with the result. You could also add a namespace filter to get only the Shop metafields with a specific name space, eg:
{
shop {
metafields(first: 100, namespace: "judgeme") {
...
...
...
}
}
}
I am working on a hydrogen project and wondering if that metafield still exists in this case
The Loox app still uses the shop.metafields.loox.global_stats as of 29 .5.2024 - in Liquid:
{{ shop.metafields.loox.global_stats }}
will output the following, eg:
4.8,3250
(e.g. 4.8 out of 5, 3250 votes cast overall)
hope that helps!
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.
No probs! Best of luck 🤞
Thank you very much ♥