# 商品ページのバリエーション在庫数表示を指定数以上の場合非表示にしたい

**URL:** <https://community.shopify.com/t/topic/149776>\
**Category:** 技術的なQ＆A\
**Created:** [September 8, 2022, 2:00am UTC](https://community.shopify.com/t/topic/149776 "2022-09-08T02:00:07Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Anonymous\_5668323578ab397108800f8626e31a2c](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@Anonymous\_5668323578ab397108800f8626e31a2c](https://community.shopify.com/u/Anonymous_5668323578ab397108800f8626e31a2c)\
**Post date:** [September 8, 2022, 2:00am UTC](https://community.shopify.com/t/topic/149776/1 "2022-09-08T02:00:07Z")

</div>

お世話になります。

初投稿の為、内容に不備などがありましたら_ご容赦いただけますと幸いです。_

■使用しているテーマ

Debutのバージョン17.12.1

■現在の状態

ヘルプセンターで紹介されていた【[商品ページにバリエーションの残りの在庫を表示する](https://help.shopify.com/ja/manual/online-store/themes/themes-by-shopify/vintage-themes/customizing-vintage-themes/show-remaining-quantity)】を利用し、商品ページ内にてバリエーション選択時にそれぞれの在庫が表示されるようにしております。

■変更したいこと

上記の在庫表示設定を、在庫が指定数以上だった場合のみ非表示という条件を追加したいです。

■試した変更

5個以上の場合非表示にしたく下記コードを試しました。  
商品ページアクセス直後は非表示となるのですが、再度該当するバリエーションを選択すると、5個以上でも在庫数が表示されてしまいました。

変更後 ※product-template.liquid内です

```auto
<div class="inventoryWrapper">
 {% if current_variant.inventory_quantity > 5 and current_variant.inventory_management == 'shopify' %}
　{% elsif current_variant.inventory_quantity > 0 and current_variant.inventory_management == 'shopify' %}
　　<p>stock: {{ current_variant.inventory_quantity }}</p>
 {% endif %}
</div>

```

変更前 ※product-template.liquid内です

```auto
<div class="inventoryWrapper">
  {% if current_variant.inventory_quantity > 0 and current_variant.inventory_management == 'shopify' %}
    <p>Stock: {{ current_variant.inventory_quantity }}</p>
  {% endif %}
</div>

```

お手数をおかけしますが、変更が必要なコードの内容をご教示頂けますと幸いです。

次回確認が9/12以降になる場合がございます。宜しくお願い致します。

---

_[View the full topic](https://community.shopify.com/t/topic/149776)._
