【问题标题】:Shopify: How do I create a new button that will redirect to the Product page?Shopify:如何创建将重定向到产品页面的新按钮?
【发布时间】:2022-11-10 13:10:49
【问题描述】:

我是新来的,对 Liquid/JSON 编码也很陌生。我正在开发一个 Shopify 项目,我需要在产品价格正下方创建一个新按钮。该按钮将显示“了解更多”,单击后会将用户引导至产品页面。我相信我找到了正确的液体文件,并且需要在此处添加代码,以便它将出现在主题的“精选集”部分中。

我不是从头开始创建新的精选集部分,而是更改主题的现有代码。

{% render 'section--featured-collection' with
 heading: section.settings.title,
 collection: collections[section.settings.collection],
 per_row: section.settings.per_row,
 rows: section.settings.rows,
 aspect_ratio: section.settings.aspect_ratio
%}

{% schema %}
 {
  "name": "t:sections.featured_collection.name",
  "class": "inline-section",
  "templates": ["404", "article", "blog", "cart", "collection", "list-collections", 
  "customers/account", "customers/activate_account", "customers/addresses", 
  "customers/login", "customers/order", "customers/register", 
  "customers/reset_password", "gift_card", "index", "page", "product", "search"],

   "settings": [
    {
     "id": "collection",
     "type": "collection",
     "label": "t:sections.featured_collection.settings.collection.label"
    },
    {
     "id": "title",
     "type": "text",
     "label": "t:sections.featured_collection.settings.title.label",
     "default": "Featured collection"
    },
    {
     "type": "range",
     "id": "per_row",
     "label": "t:sections.featured_collection.settings.per_row.label",
     "min": 2,
     "max": 4,
     "step": 1,
     "default": 3
    },
    {
     "type": "range",
     "id": "rows",
     "label": "t:sections.featured_collection.settings.rows.label",
     "min": 1,
     "max": 3,
     "step": 1,
     "default": 1
    },
    {
     "id": "aspect_ratio",
     "type": "select",
     "label": "t:shared.aspect_ratio.label",
     "options": [
      { "label": "t:shared.aspect_ratio.options.natural", "value": "natural" },
      { "label": "t:shared.aspect_ratio.options.square", "value": "square" },
      { "label": "t:shared.aspect_ratio.options.landscape", "value": "landscape" },
      { "label": "t:shared.aspect_ratio.options.portrait", "value": "portrait" }
     ],
     "default": "natural"
    }    
   ],
  "presets": [
  {
    "name": "Featured collection",
    "category": "Collection",
    "settings": {}
  }
  ]
  }
 {% endschema %}

对此的任何帮助将不胜感激,并提供巨大的帮助!谢谢!

【问题讨论】:

    标签: shopify liquid


    【解决方案1】:

    在您的section--featured-collection sn-p 中,当循环访问精选系列的产品时,使用product.url 属性引用每个产品的url 是非常标准的。

    {% for product in collection.products %}
      # Typically more information, like product image, title and price
      <a href="{{ product.url }}">Learn More</a>
    {% endfor %}
    

    您可以在Shopify doc 中找到有关产品属性的更多信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-09
      • 1970-01-01
      相关资源
      最近更新 更多