逻辑如下:默认全部售卖,如果变体配置了元字段,就只在元字段当前国家进行售卖
增加元字段
配置里面使用的是 ISO 3166-1 (alpha 2) 格式的国家代码,具体可以去 wiki 进行查询
https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes
字段名称:可自行设置,此名称为展示在店铺后台的名称
命名空间:show_country
密钥:show_country_key
数据类型:单行文本
赋值类型:多个值
修改主题代码
将 blocks/product/_detail-variant-picker.html 以下部分,替换为下方代码
<script name="variant-data" type="application/json">
[
{{#var has_output /}}
{{#set has_output = 0 /}}
{{#for variant in product | get_variants() ~}}
{{#var show_variant /}}
{{#set show_variant = 1 /}}
{{#var show_country = variant | get_metafields("show_country") /}}
{{#if show_country.show_country_key.value }}
{{#set show_variant = 0 /}}
{{/if}}
{{#for show_country_key in show_country.show_country_key.value ~}}
{{#if localization.country.iso_code == show_country_key }}
{{#set show_variant = 1 /}}
{{/if}}
{{/for}}
{{#if show_variant == 1 }}
{{#if has_output == 1 }},{{/if}}
{{#component "product/variant-data" variant=variant /}}
{{#set has_output = 1 /}}
{{/if}}
{{/for}}
]
</script>


