Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shopify 更改所有产品的颜色标题_Shopify_Liquid - Fatal编程技术网

Shopify 更改所有产品的颜色标题

Shopify 更改所有产品的颜色标题,shopify,liquid,Shopify,Liquid,我正在尝试将变体标题“颜色”改为“味道”。我试图在代码中更改它,但没有起作用。我有数千种产品,每一种都要改变颜色,这将是一个很大的工作。标题颜色显示的代码如下所示。这可能吗 <select name="id" id="productSelect" class="product-variants"> {% for variant in product.variants %} {% if variant.available %} <option {% if

我正在尝试将变体标题“颜色”改为“味道”。我试图在代码中更改它,但没有起作用。我有数千种产品,每一种都要改变颜色,这将是一个很大的工作。标题颜色显示的代码如下所示。这可能吗

<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>

{product.variants%中的变量为%0}
{%if variant.available%}
{{variant.title}}-{{variant.price}货币}
{%else%}
{{variant.title}}-{{'products.product.salled|t}
{%endif%}
{%endfor%}

这可以使用Shopify API完成

有关完整工作的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"}
    ]
    }

};