Howto check if current visitor is shop's admin?

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

    This is a more complete version of that provided by kyle.stearns above (I can't comment on it because new). One of the main instances where admin bar doesn't load is when previewing themes. Here is the amended code which I've used (updated June 2018 - as Shopify edited the way we preview themes):

      {% capture CFH %}{{ content_for_header  }}{% endcapture %}
    
    {% if CFH contains 'admin_bar_iframe' %}
    {% assign admin = true %}
    {% elsif CFH contains 'preview_bar_injector-' %}
    {% assign admin = true %}
    {% endif %}
    
    {% if admin %}
    
    
    {% else %}
    
    
    {% endif %}
    

    If you're using Plus then you also have access to the User via api.

提交回复
热议问题