模板脚本,使其仅对 shopify 上的管理员可见
Template script to make it visible only to admin on shopify
我想让 shopify 上的模板只对管理员可见。
我可以让它只对客户可见,但现在只需要管理员代码。
我使用的客户代码是:
{% unless customer %}
{% if template contains 'customer' %}
{% assign send_to_login = false %}
{% else %}
{% assign send_to_login = true %}
{% endif %}
{% endunless %}
{% if send_to_login %}
<meta content="0; url=/account/login?checkout_url={{ shop.url }}" http-equiv="refresh" />
{% else %}
==== Page Content ===
{% endif %}
//The code above asks to the user to login if they visit this template
现在是否可以为管理员制作类似的东西?管理实体的名称是什么?例如这里的实体客户是'customer'。我应该如何在代码中声明管理员?
提前致谢。
查看这些类似的问题:
- How to check if current visitor is shop's admin
- Check if current customer is an admin in Shopify?
- Check if current customer/user is an admin on product or collection pages?
目前没有像检查客户那样检查管理员的好方法。您的选择是 tag your customers as admins and only show your template if the customer has the admin tag, or check against the customer's email address 以确定他们是否是管理员。
我想让 shopify 上的模板只对管理员可见。 我可以让它只对客户可见,但现在只需要管理员代码。
我使用的客户代码是:
{% unless customer %}
{% if template contains 'customer' %}
{% assign send_to_login = false %}
{% else %}
{% assign send_to_login = true %}
{% endif %}
{% endunless %}
{% if send_to_login %}
<meta content="0; url=/account/login?checkout_url={{ shop.url }}" http-equiv="refresh" />
{% else %}
==== Page Content ===
{% endif %}
//The code above asks to the user to login if they visit this template
现在是否可以为管理员制作类似的东西?管理实体的名称是什么?例如这里的实体客户是'customer'。我应该如何在代码中声明管理员? 提前致谢。
查看这些类似的问题:
- How to check if current visitor is shop's admin
- Check if current customer is an admin in Shopify?
- Check if current customer/user is an admin on product or collection pages?
目前没有像检查客户那样检查管理员的好方法。您的选择是 tag your customers as admins and only show your template if the customer has the admin tag, or check against the customer's email address 以确定他们是否是管理员。