【问题标题】:Change Color title for all products更改所有产品的颜色标题
【发布时间】:2015-10-26 17:18:12
【问题描述】:

我正在尝试将变体标题“颜色”更改为“风味”。我试图在代码中更改它但不起作用。我有数以千计的产品,为每种产品更改颜色将是很多工作的方式。下面列出了标题颜色显示的代码。这甚至可能吗?

<select name="id" id="productSelect" class="product-variants">
  {% for variant in product.variants %}
    {% if variant.available %}

      <option {% if variant == product.selected_or_first_available_variant %} selected="selected" {% endif %} value="{{ variant.id }}">{{ variant.title }} - {{ variant.price | money_with_currency }}</option>

    {% else %}
      <option disabled="disabled">
        {{ variant.title }} - {{ 'products.product.sold_out' | t }}
      </option>
    {% endif %}
  {% endfor %}
</select>

【问题讨论】:

    标签: shopify liquid


    【解决方案1】:

    这可以使用 Shopify API 来完成。

    请参阅 this answer 以获得完整的 node.js 脚本。它创造了一个产品。要更新产品,您必须获取所有具有颜色作为变体名称的产品并运行如下内容:

    var options = {
      host: 'mydomain.myshopify.com',
      port: 443,
      path: '/admin/products/1925263361.json', // per product
      method: 'PUT',
      headers: headers
    };
    ...
    var product = {
      product:{
        id:'1925263361',
        options : [ // just update the variant titles; no other fields
          {name : "Bob"}, //was First
          {name : "Carol"}, // was Second
          {name : "Third"}
        ]
        }
    
    };
    

    【讨论】:

      猜你喜欢
      • 2022-01-16
      • 1970-01-01
      • 2017-04-11
      • 1970-01-01
      • 1970-01-01
      • 2021-02-08
      • 1970-01-01
      • 2019-04-27
      • 1970-01-01
      相关资源
      最近更新 更多