Howto check if current visitor is shop's admin?

后端 未结 6 1046
小蘑菇
小蘑菇 2020-12-19 07:07

I would like to create a product that would be available in Shopify\'s storefront but would only be accessible for the shop administrator. Is there anyway to identify if the

6条回答
  •  臣服心动
    2020-12-19 07:29

    Another approach would be to use Customer Accounts. Liquid provides a {{ customer }} object, which is only present when a user (customer) is logged in.

    You can add a specific tag to an admin user and use liquid to verify if a tag is present:

    {% if customer.tags contains "admin" %}
    

    And of course you need to identify your product as 'admin-only', for example using tags:

    {% if customer.tags contains "admin" and product.tags contains "admin" %}
      
    {% else %}
      
    {% endif %}
    

提交回复
热议问题