Metafields字段的产品版本
我想在产品卡上显示不同版本的产品。我在Metafields部分中创建了一个适当的字段,但我无法实施它。
我已经准备好代码,但是它不做我想要的,因为没有显示任何图像,产品名称,也没有显示任何价格。
我应该如何更改代码以使其正常工作?
<ul class="recommended-products">
{% if product.metafields.my_fields.product_version != blank %}
{% assign product_version = product.metafields.my_fields.product_version %}
<li>
<a href="{{ product_version.url }}" target="_blank">
<img src="{{ product.metafields.my_fields.product_version.featured_image | img_url: '100x' }}">
<div>
<p>{{ product_version.title }}</p>
<p class="uaf__price">{{product_version.price | money }}</p>
</div>
</a>
</li>
{% endif %}
</ul>
I have different versions of products that I would like to display on the product card. I created a proper field in the metafields section, but I am unable to implement it.
I have a code ready, but it does not work as I would like it because nothing is displayed, neither the image, nor the name of the product, nor the price.
How should I change the code to make it work?
<ul class="recommended-products">
{% if product.metafields.my_fields.product_version != blank %}
{% assign product_version = product.metafields.my_fields.product_version %}
<li>
<a href="{{ product_version.url }}" target="_blank">
<img src="{{ product.metafields.my_fields.product_version.featured_image | img_url: '100x' }}">
<div>
<p>{{ product_version.title }}</p>
<p class="uaf__price">{{product_version.price | money }}</p>
</div>
</a>
</li>
{% endif %}
</ul>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我很长时间以来一直陷入这个问题,终于找到了一个
仅液体
解决方案。这是您的工作方式:您可以选择“一种产品”或“产品列表”,我将向您展示如何与两者一起使用。
3.A.如果您选择了“一种产品”:
3.b。如果您选择了“产品列表”,请这样循环:
I was stuck in this problem for ages, I finally found a
liquid only
solution. Here is how you do it:You can select either "One Product" or "List of products", I will show you how to work with both.
3.a. If you have selected "one product":
3.b. If you have selected "List of products", loop through them like this: