# 商品タイプの異なる商品の同時購入制限について

**URL:** <https://community.shopify.com/t/topic/137898>\
**Category:** 総合的なディスカッション\
**Created:** [July 26, 2022, 2:34am UTC](https://community.shopify.com/t/topic/137898 "2022-07-26T02:34:06Z")\
**Posts on this page:** 2\
**Page:** 1

## AI-generated summary

- 課題: 商品タイプが異なる場合（例: 通常商品と限定商品）の同時購入を禁止したい。Dawnテーマにはcart-template.liquidがないため、設定箇所の特定が必要。

- 解決: Dawnではmain-cart-footer.liquidに実装することで対応可能と報告。

- 実装方針: カート内の各商品のproduct.tagsを走査し、「通常商品」「限定商品」タグを検出してtypeA/typeBフラグを設定。

- 条件制御: 両フラグがtrue（両タイプが混在）なら購入ボタンを非表示にし、注意メッセージを表示して同時購入を禁止。

- コード差分: 既存の購入ボタン部分をLiquidの条件分岐に置き換え。additional_checkout_buttons（Shopifyの別決済ボタン）はそのまま表示可能。

- 状態: 要件は実装できたとの報告で、現時点で解決済み。理解には提示されたコード断片が中心。

<div class="post-metadata">

**Author:** ![ponuco](https://avatars.discourse-cdn.com/v4/letter/p/b487fb/32.png) [@ponuco](https://community.shopify.com/u/ponuco)\
**Post date:** [July 26, 2022, 2:34am UTC](https://community.shopify.com/t/topic/137898/1 "2022-07-26T02:34:06Z")

</div>

商品タイプが異なる場合に、複数の商品を同時購入できなくするように設定したいです。

下記の回答を参考にしてみたのですが、dawnのテーマを使用しているため「cart-template.liquid」ファイルがありません。

dawnテーマの場合は、どのファイルに設定すれば購入制限をかけられるようになりますか？

[https://community.shopify.com/post/1107122](https://community.shopify.com/post/1107122)

---

<div class="post-metadata">

**Author:** ![ponuco](https://avatars.discourse-cdn.com/v4/letter/p/b487fb/32.png) [@ponuco](https://community.shopify.com/u/ponuco)\
**Post date:** [July 27, 2022, 7:15am UTC](https://community.shopify.com/t/topic/137898/2 "2022-07-27T07:15:26Z")

</div>

「main-cart-fotter.liquid」に設定したらできました。

ファイル内の下記「購入ボタン」のコードがある部分を

```markup
<　button type="submit" id="checkout" class="cart__checkout-button button" name="checkout"{% if cart == empty %} disabled{% endif %} form="cart">
        {{ 'sections.cart.checkout' | t }}

 {%- if additional_checkout_buttons -%}
  　　
     {{ content_for_additional_checkout_buttons }}
   

　　{%- endif -%}

```

下記のように置き換えたら購入ボタンの表示・非表示が可能になりました。

```markup
{%- comment -%}
---------------------------------------------------------------------
        同時購入禁止
---------------------------------------------------------------------
{%- endcomment -%}
            
{%- for item in cart.items -%}
    {%- for tag in item.product.tags -%}
        {%- if tag == '通常商品' -%}
            {% assign typeA = true %} 
        {%- endif -%}
        {%- if tag == '限定商品' -%}
            {% assign typeB = true %}
        {%- endif -%}
    {%- endfor -%}
{%- endfor -%}

{%- unless typeA == true and typeB == true -%}
    
{%- endunless -%}
            
  {%- if typeA == true and typeB == true -%}
  

  【注意】
通常商品と限定商品を同時に購入することはできません。

  お手数ですがカートからどちらかの商品を削除してページをしてください。
  

  {%- endif -%}

 {%- if additional_checkout_buttons -%}
  　　
     {{ content_for_additional_checkout_buttons }}
   

　　{%- endif -%}

```
