Howto check if current visitor is shop's admin?

后端 未结 6 1042
小蘑菇
小蘑菇 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:12

    EDIT: This seems not to be working anymore since an update to Shopify.


    I know this is late, but here is what I've used and it has worked correctly in my testing. This is adapted from the previous answers, but allows use for Customise Theme options, etc.

    {% capture CFH %}{{ content_for_header }}{% endcapture %}{{ CFH }}
    
    {% assign isAdmin = true %}
    
    {% if CFH contains '"__st"' %}
        {% if CFH contains 'admin_bar_iframe' %}{% else %}
            {% assign isAdmin = false %}
        {% endif %}
    {% endif %}
    

提交回复
热议问题