In this forum topic, one of the Shopify Experts mentions it's possible to access coookies from the script editor. Can someone give me an example of how to do that?
Thanks!
I don't think the user giving the answer in that post fully understood the context of the question. Shopify Scripts run on the back end of Shopify servers so they definitely won't have access to anything like a cookie, which exists only in the client's browser.
You could achieve something along these lines by:
(1) Using Javascript to insert a custom, hidden line item property to any add to cart forms on your site if customers have a specific cookie in their browser;
(2) On the backend, have your Shopify scripts read that line item property and perform custom behaviour based on that.
The standard approach to "hide" line item properties is to prefix them with an underscore (eg "_cookie"), then update your theme and email templates to avoid showing customers these values.