简体   繁体   English

试图找到一种只在Shopify中显示一段脚本的方法。

[英]Trying to find a way to only display a section of script once in Shopify.

I have previously used {% if first_time_accessed %} to handle this condition for the order status / checkout receipt pages, but I'm now trying to only display something the first time that it is accessed. 我之前使用{%if first_time_accessed%}来处理订单状态/结账收据页面的这种情况,但我现在只是尝试在第一次访问时显示某些内容。

For clarity, this is the structure of the content: 为清楚起见,这是内容的结构:

// Check User is logged in
{% if customer %}
  // Check that the pixel has not yet been displayed
  {% if INSERT CONDITION FOR FIRST ITERATION HERE %}

    // Run JS Script

So ideally the if customer will cause the JS script to run only on the first page the customer visits after logging into their account. 理想情况下,if客户是否会导致JS脚本仅在客户登录其帐户后访问的第一页上运行。

Any thoughts or suggestions on how to achieve this would be great. 任何关于如何实现这一点的想法或建议都会很棒。 I'm beginning to think the easy approach would be to set a cookie with the status for this condition but that seems like a long way around it. 我开始认为简单的方法是设置一个具有此条件状态的cookie,但这似乎有很长的路要走。

Thanks! 谢谢!

解决方案需要是javascript,因为在Liquid中没有任何操作,除了你提到的Checkout页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM