markdown 将语言设置添加到“显示特色图像,直到选择变体”帮助文档

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 将语言设置添加到“显示特色图像,直到选择变体”帮助文档相关的知识,希望对你有一定的参考价值。

**Theme:** Debut

**Version(s) successfully tested on:** 	12.2.1

**Recommended design time:** 5 min

-----

# What you have
![screenshot](https://screenshot.click/2019-07-04_14-50-55.jpg)
# What you want
![screenshot](https://screenshot.click/2019-07-04_14-58-05.jpg)
----
# Background

Currently, when the "Show featured image until a variant is selected" Help Document is implemented, it changes the variant selector on the product page to say "Pick a [variant]". In English, if the variant type name starts with a vowel, this creates a grammatical error. It is incorrect to use an 'a' in front of a word starting with a vowel. One must use an "an".

Additionally, if the merchant's store is in another language, there is no way (other than modifying the code) to change "Pick a" to a phrase in their store's language.

As you can see in the image under the "What you have" heading, implementing the tutorial as it stands results in a grammatical error if the variant type starts with a vowel. 

This modification to the Help Document is intended to allow merchant's to choose another variant selector phrase other than "Pick a" via a language setting.

# How you get it 

After following [the Help Doc instructions](https://help.shopify.com/en/themes/customization/products/variants/show-featured-image-on-product-page).

**Step 1:** Replace the code you copied into the bottom of the theme.js file with the code below.

```
$(document).ready(function() {
  if( typeof(productOptions ) != "undefined" ){
    for(i=0;i<productOptions.length;i++) {
      $('.single-option-selector:eq('+ i +')')
      .filter(function() {
        return $(this).find('option').length > 1
      })
      .prepend('<option value="">' + pickVariantLanguage + ' ' + productOptions[i][i] + '</option>')
      .val('')
      .trigger('change');
    }
  }
});
  ```

**Step 2:** Replace the script you copied at the bottom of the product-template.liquid file with this.

```
<script>
var productOptions = [];
  {% for option in product.options %}
  var optionObj = {};
  optionObj[ {{ forloop.index0 }} ] = "{{ product.options[forloop.index0] }}";
  productOptions.push(optionObj);
  {% endfor %}
  var pickVariantLanguage = "{{ 'products.product.select_variant' | t  }}"
</script>
```
**Step 3:** Add the following language setting underneath "unavailable" in the en.default.json file (or whatever language the merchant is using).
```
"select_variant": "Select your"
```
---

Now the merchant can change the "Pick a" phrase to something else (I would suggest "Pick your") in their theme's language settings. 

**Alternative keywords:** variant, select, language, pick, featured image

以上是关于markdown 将语言设置添加到“显示特色图像,直到选择变体”帮助文档的主要内容,如果未能解决你的问题,请参考以下文章

如何使用 $wpdb 类在 wordpress 中显示特色图像

markdown 将模块设置页面添加到admin / config页面

新功能发布!Markdown写博客!

Markdown语法说明

博客园添加markdown文章导航栏

markdown 将图像添加到Gist.markdown中的markdown文件