# 並び替えの「アルファベット順」を削除したい

**URL:** <https://community.shopify.com/t/topic/194659>\
**Category:** 技術的なQ＆A\
**Created:** [February 24, 2023, 8:36am UTC](https://community.shopify.com/t/topic/194659 "2023-02-24T08:36:22Z")\
**Posts on this page:** 5\
**Page:** 1

## AI-generated summary

ユーザーがShopifyのコレクション並び替えオプションから「アルファベット順, A-Z」を削除する方法を質問。

**初期の問題:**
Debut 17.4.1テーマを使用中、`title-ascending`（アルファベット順 A-Z）のみ非表示にしたいが、コードが正しく動作していない。

**原因:**
使用していたif文の条件が「A-Zではない または Z-Aである」となっており、論理エラーがあった。

**解決策:**
コードを以下のように修正:
- 修正前: `{% if option.value != "title-ascending" or option.value == "title-descending" %}`
- 修正後: `{% if option.value != "title-ascending" and option.value != "title-descending" %}`

`or`を`and`に変更することで、両方のアルファベット順オプションを正しく非表示にできる。

**結果:**
ユーザーは無事実装に成功し、問題は解決済み。

<div class="post-metadata">

**Author:** ![dzmeya2](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@dzmeya2](https://community.shopify.com/u/dzmeya2)\
**Post date:** [February 24, 2023, 8:36am UTC](https://community.shopify.com/t/topic/194659/1 "2023-02-24T08:36:22Z")

</div>

並び替えの「アルファベット順, A-Z」、「アルファベット順, Z-A」を削除するコードをご教授下さい。

---

<div class="post-metadata">

**Author:** ![kyoshi\_Tsun](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/kyoshi_tsun/32/1503_2.png) [@kyoshi\_Tsun](https://community.shopify.com/u/kyoshi_Tsun)\
**Post date:** [February 25, 2023, 1:22am UTC](https://community.shopify.com/t/topic/194659/2 "2023-02-25T01:22:13Z")

</div>

はじめまして

株式会社Tsunの吉谷と申します

Dawn 8.0.0の内容になりますが、こちらの記事が参考なりましたら幸いです。

[コレクションの並び替え（ソート）項目を非表示にする方法](https://tsun.ec/blogs/tech/shopify-tips-hide-sort-options)

以上になります。

---

<div class="post-metadata">

**Author:** ![dzmeya2](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@dzmeya2](https://community.shopify.com/u/dzmeya2)\
**Post date:** [February 27, 2023, 2:01am UTC](https://community.shopify.com/t/topic/194659/3 "2023-02-27T02:01:54Z")

</div>

返信ありがとうございます。生憎ですがDebut 17.4.1を使っています。

試したコードは下記なのですが、「アルファベット順, A-Z」である"title-ascending"しか非表示にならず、もし解決策をご存知でしたら教えてほしいです。

```markup
{%- for option in collection.sort_options -%}
  {% if option.value != "title-ascending" or option.value == "title-descending" %}
    
  {% endif %}

```

---

<div class="post-metadata">

**Author:** ![kyoshi\_Tsun](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/kyoshi_tsun/32/1503_2.png) [@kyoshi\_Tsun](https://community.shopify.com/u/kyoshi_Tsun)\
**Post date:** [February 27, 2023, 4:16am UTC](https://community.shopify.com/t/topic/194659/4 "2023-02-27T04:16:03Z")

</div>

記載しているコードは、

if文の条件が「アルファベット順, A-Zではない または アルファベット順, Z-Aである」の条件になってますので、「アルファベット順, A-Z」だけが非表示になっています。

下記のようにコードを修正し、再度試してみてもらえると幸いです

修正前

```markup
{% if option.value != "title-ascending" or option.value == "title-descending" %}

```

修正後

```markup
{% if option.value != "title-ascending" and option.value != "title-descending" %}

```

---

<div class="post-metadata">

**Author:** ![dzmeya2](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@dzmeya2](https://community.shopify.com/u/dzmeya2)\
**Post date:** [February 27, 2023, 7:01am UTC](https://community.shopify.com/t/topic/194659/5 "2023-02-27T07:01:41Z")

</div>

大変勉強になりました。無事実装することができました。ありがとうございました。
