Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/442.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
Javascript 在shopify中重命名大小变量标题_Javascript_Shopify_Liquid - Fatal编程技术网

Javascript 在shopify中重命名大小变量标题

Javascript 在shopify中重命名大小变量标题,javascript,shopify,liquid,Javascript,Shopify,Liquid,我正在试图找到一种方法,自动将尺码变体的大小重命名为S M L XL XXL。中大号x-large xx大号xxx大号。。等等 我之所以要重命名尺寸变量,是因为占用了大量的额外空间 我正在从一个应用程序创建产品,该应用程序不允许我在shopify中创建产品之前更改尺寸变体的名称。手动更改每种产品的变体名称是没有意义的,因为这样做没有时间效率 我认为最好的方法是使用Javascript,但我不知道如何做到这一点,这样它就不会破坏任何东西 下面是一个中等大小变体的HTML源代码示例 <div

我正在试图找到一种方法,自动将尺码变体的大小重命名为S M L XL XXL。中大号x-large xx大号xxx大号。。等等

我之所以要重命名尺寸变量,是因为占用了大量的额外空间

我正在从一个应用程序创建产品,该应用程序不允许我在shopify中创建产品之前更改尺寸变体的名称。手动更改每种产品的变体名称是没有意义的,因为这样做没有时间效率

我认为最好的方法是使用Javascript,但我不知道如何做到这一点,这样它就不会破坏任何东西

下面是一个中等大小变体的HTML源代码示例

<div data-value="Medium" class="swatch-element medium-swatch available"> <label for="swatch-1-medium-286472667159">
            Medium <span class="crossed-out"></span></label></div>
样本的液体来源

    <div class="swatch clearfix" data-option-index="{{ option_index }}">
  <div class="option_title">{{ swatch }}</div>
  {% assign values = '' %}
  {% for variant in product.variants %}
    {% assign value = variant.options[option_index] %}
    {% unless values contains value %}
      {% assign values = values | join: ',' %}
      {% assign values = values | append: ',' | append: value %}
      {% assign values = values | split: ',' %}

      <input id="swatch-{{ option_index }}-{{ value | handle }}-{{ product.id }}" type="radio" name="option-{{ option_index }}" value="{{ value | escape }}"{% if forloop.first %} checked{% endif %} />
      <div data-value="{{ value | escape }}" class="swatch-element {% if is_color %}color {% endif %}{{ value | handle }}-swatch {% if variant.available %}available{% else %}soldout{% endif %}">
        {% if is_color %}
          <div class="tooltip">{{ value }}</div>
        {% endif %}
        {% if is_color %}
          <label for="swatch-{{ option_index }}-{{ value | handle }}-{{ product.id }}" style="background-image: url({{ value | handle | append: '.' | append: file_extension | asset_img_url: '50x' }}); background-color: {{ value | split: ' ' | last | handle }};">
            <span class="crossed-out"></span>
          </label>
        {% else %}
          <label for="swatch-{{ option_index }}-{{ value | handle }}-{{ product.id }}">
            {{ value }}
            <span class="crossed-out"></span>
          </label>
        {% endif %}
      </div>
    {% endunless %}
  {% endfor %}
</div>

作为解决办法,我可以这样建议您:

以纯CSV格式从Shopify导出产品 在excel中打开CSV文件 使用“查找并替换”重命名excel中的所有尺寸变量 再次导入Shopify确保已选择覆盖具有相同句柄的现有产品