隱藏「加入購物車」按鈕

您可以在店面隱藏「加入購物車」按鈕,並在未來再次顯示。

區段式佈景主題和非區段式佈景主題

Sectioned
  1. 在 Shopify 管理介面 中,前往「線上商店」>「佈景主題」。
  2. 找到要編輯的佈景主題,按一下「...」按鈕以開啟動作選單,然後點擊「編輯程式碼」。
  3. 在「區段」目錄中,點擊以開啟 product-template.liquid 檔案。找到加入購物車」按鈕的 HTML 程式碼。您可以從搜尋「cart (購物車)」一字開始。

「加入購物車」按鈕的程式碼因佈景主題而異。您可以搜尋 <input><button> 標籤,其中包含 Add to cartAddToCartadd-to-cart 文字。

在 Debut 佈景主題中,「加入購物車」按鈕程式碼應如下所示:

<button type="submit" name="add" id="AddToCart-{{ section.id }}" {% unless current_variant.available %}disabled="disabled"{% endunless %} class="btn product-form__cart-submit{% if product.options.size == 1 and product.variants[0].title == 'Default Title' %} product-form__cart-submit--small{% endif %}">
  <span id="AddToCartText-{{ section.id }}">
    {% unless current_variant.available %}
      {{ 'products.product.sold_out' | t }}
    {% else %}
      {{ 'products.product.add_to_cart' | t }}
    {% endunless %}
  </span>
</button>
  1. 若您找到該段程式碼,請將程式碼置於 Liquid 標籤「{% comment %}」和「{% endcomment %}」之間。這將防止程式碼顯示於商店中,而且如果您之後要變更新的範本,這麼做也有利於放回這段程式碼。

應用上方的範例後,新程式碼應會如下所示:

{% comment %}
<button type="submit" name="add" id="AddToCart-{{ section.id }}" {% unless current_variant.available %}disabled="disabled"{% endunless %} class="btn product-form__cart-submit{% if product.options.size == 1 and product.variants[0].title == 'Default Title' %} product-form__cart-submit--small{% endif %}">
  <span id="AddToCartText-{{ section.id }}">
    {% unless current_variant.available %}
      {{ 'products.product.sold_out' | t }}
    {% else %}
      {{ 'products.product.add_to_cart' | t }}
    {% endunless %}
  </span>
</button>
{% endcomment %}
  1. 按一下「儲存」來確認變更內容。

若您準備好重新顯示「加入購物車」按鈕,請回到「編輯 HTML/CSS 頁面」的 product-template.liquid 檔案並移除 {% comment %}{% endcomment %} 標籤,然後按一下「儲存」。

Non-sectioned
  1. 在 Shopify 管理介面 中,前往「線上商店」>「佈景主題」。
  2. 找到要編輯的佈景主題,按一下「...」按鈕以開啟動作選單,然後點擊「編輯程式碼」。
  3. 在「範本」目錄中,點擊以開啟 product.liquid 檔案。找到加入購物車」按鈕的 HTML 程式碼。您可以從搜尋「cart (購物車)」一字開始。

「加入購物車」按鈕的程式碼因佈景主題而異。您可以搜尋包含 Add to cartAddToCartadd-to-cart 等文字的 <input><button> 標籤。

在 Minimal 佈景主題中,「加入購物車」按鈕程式碼應如下所示:

<button type="submit" name="add" id="AddToCart" class="btn">
  <span id="AddToCartText">{{ 'products.product.add_to_cart' | t }}</span>
</button>
  1. 若您找到該段程式碼,請將程式碼置於 Liquid 標籤「{% comment %}」和「{% endcomment %}」之間。這將防止程式碼顯示於商店中,而且如果您之後要變更新的範本,這麼做也有利於放回這段程式碼。

應用上方的範例後,新程式碼應會如下所示:

{% comment %}
<button type="submit" name="add" id="AddToCart" class="btn">
  <span id="AddToCartText">{{ 'products.product.add_to_cart' | t }}</span>
</button>
{% endcomment %}
  1. 按一下「儲存」來確認變更內容。

若您準備好重新顯示「加入購物車」按鈕,請回到「編輯 HTML/CSS 頁面」的 product.liquid 範本並移除 {% comment %}{% endcomment %} 標籤,然後按一下「儲存」。

沒有找到您需要的答案嗎?我們很樂意為您提供協助。