【问题标题】:Shopify link directly to other itemShopify 直接链接到其他项目
【发布时间】:2013-11-13 19:59:42
【问题描述】:

我的 shopify 商店中有一些商品具有相似的主题商品,非常适合它。

我知道我可以在其中添加一个 <a href 链接,但我想做一些实际上是流动性的事情,并且对于我的非程序员合作伙伴(他也有权让我睡在沙发上 :-( ...) 添加这些链接。有没有办法使用液体格式添加链接?像This would go great with ${items.ellington-coffee-table-set}! 这样的东西?

【问题讨论】:

    标签: shopify liquid


    【解决方案1】:

    能够访问像collections.my-collection-handle.products.my-product-handle 这样的产品会很棒,但不幸的是it is not possible to get a product by its handle in liquid

    您必须遍历集合才能找到这样的产品:

    {% for product in collections.my-collection-handle.products %}
        {% if product.handle == 'my-product-handle' %}
            {{ 'my product' | link_to: product.url }}
        {% endif %}
    {% endfor %}
    

    但是,如果您想要的只是产品的链接,那看起来很混乱,而且您仍然必须对产品的句柄进行硬编码。这会更简单:

    {{ 'my product' | link_to: '/products/my-product-handle' }}
    

    仍然不理想,但可能比手动编写 <a href=... 链接更好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-07
      • 2022-01-22
      相关资源
      最近更新 更多