Similar post as https://community.shopify.com/post/569714. I put a reply there, which isn’t a solution but has some additional details.
Topic summary
Goal: Allow restricted product pages to be visible to store owner/staff from the storefront by detecting an admin/staff session via Liquid or cookies.
Workarounds/Implementations:
- A practical workaround is to create a special “master customer” and gate logic by checking the logged-in customer’s ID on the frontend. This avoids dealing with admin cookies and is quicker to implement.
Technical approach with Liquid (and its evolution):
- Previously: Check Liquid’s content_for_header for ‘adminBar’ to detect an admin session.
- Update (Oct 2024): Use ‘previewBar’ instead of ‘adminBar’. Example: {% if content_for_header contains ‘previewBar’ %} Admin Detected {% endif %}
Current limitation:
- As of Oct 2024, the ‘previewBar’ method only detects admins when in Theme Preview/Editor. It does not work during normal browsing; ‘adminBar’ no longer appears.
Status/Outcome:
- No native, reliable method to detect staff/owner on the live storefront outside Preview Mode. The thread remains effectively unresolved; the recommended practical path is the “master customer” approach. Code snippets are central to understanding the detection method and its limitations.