我如何为fancybox单击打开Shopify的产品分配变量

问题描述

我需要在shopify中为产品分配一个javascript变量,以便在单击快速商店fancybox时将正确的变量分配给正在查看的产品。

我认为一种方法是分配一个变量,该变量在shopify加载收集页面时以某种方式分配给产品。

另一种方法是,是否可以在点击和加载fancybox quickshop时为被点击的产品分配变量。

<span data-fancybox-href="#product-{{ product.id }}" class="quick_shop action_button" data-gallery="product-{{ product.id }}-gallery">

当我在实际的单个产品页面上使用以下代码时,这很好,因为该页面会加载并分配变量。

<script>    
  var shipMsg = "Product-Thumbnail Ship Message";   
</script>

{% for tag in product.tags %}
{%if tag contains '_Ship2-4' %}
            <script>
              shipMsg = 'Arrives in 2400'
            </script>
            <p>2400 selected</p>
    
{%elsif tag contains '_Ship7' %}
            <script>
              shipMsg = 'Arrives in 700'
            </script>
<p>7 selected</p>
              
{%endif%}
{%endfor%}
              
<p class="ship_message"></p>

由于我打开Quickshop弹出窗口时可以看到正确的产品标签,并且设置的触发器显示if语句已正确运行,因此我的想法用光了。我只需要在单击弹出窗口时将变量分配给特定产品。

希望这有道理。

感谢您的时间!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)