書類のダウンロードボタンを条件によってグレーアウトしたい

AI-generated summary

The request is to gray out and disable order-document download buttons in Shopify according to fulfillment and payment conditions: estimates are always available; delivery notes require all items to be shipped; invoices are unavailable for Shopify Payments or mobile payments; and receipts require both full payment and shipment of all items.

A reply proposed CSS for a disabled appearance and Liquid checks using each line item’s remaining fulfillable quantity, the order’s payment status, and its payment gateway. However, the examples show the same button label in both branches and do not provide complete link-disabling logic, so the implementation would need further adjustment and testing.

The latest update adds an important limitation: Liquid in theme templates applies only to legacy customer accounts, which Shopify is deprecating. New customer accounts do not use those templates; equivalent buttons require a customer-account UI extension, built in-house or provided by an app. The discussion does not establish a tested, complete solution for either account type.

Shopifyのプランは「Basic」、テーマは「Rise」を使っています。

テーマのコードの直接編集ではなく、テーマのカスタマイズで作成しています。

セクションの「カスタムliquid」に以下のコードで、【お客様の注文】ページに書類のダウンロードボタンとリンクを設定しました。(リンクはダミーです)


## **書類ダウンロード**

以下のボタンから各書類がダウンロードいただけます。

  

    
      見積書
    

    
      納品書
    

    
      請求書
    

    
      領収書
    
  

<b>※納品書・領収書は、ご注文商品全ての発送完了後にダウンロードいただけます。
※クレジットカード決済、スマホ決済(QRコード決済)では、各決済会社からのご請求となるので請求書はダウンロードできません。領収書をご利用ください。</b>

こちらについて、以下の条件でダウロード不可状態にしたいです。

具体的には、ボタンをグレーアウトし、クリックもできないようにしたいです。

  • 見積書:無条件でいつでもダウロード可能。
  • 納品書:支払状況に関係なく、発送済みの場合のみダウロード可能。(一部のみ発送済みはダウンロード不可)
  • 請求書:支払状況・配送状況に関係なく、支払方法でShopifyPaymentまたはスマホ決済の場合はダウンロード不可。
  • 領収書:全額支払済みかつ全て発送済みの場合のみダウロード可能。

具体的なコードを教えていただけると助かります。

よろしくお願いいたします。

@n_ogawa3 様

書類のダウンロードボタンを条件によってグレーアウトしたい件ですが、抜粋で調整内容を記載させていただきます。

1.CSSで無効化スタイルを追加

.disabled-button {
  background-color: #e9ecef;
  border-color: #ced4da;
  color: #6c757d;
  cursor: not-allowed;
  opacity: 0.65;
  pointer-events: none;
  box-shadow: none;
}

2.Liquidで条件分岐を追加

見積書ボタン

常にダウンロード可能なので、特別な条件分岐は不要です。

納品書ボタン
すべての商品が発送済みかどうかを確認します。

{% assign all_fulfilled = true %}
{% for line_item in order.line_items %}
  {% if line_item.fulfillable_quantity > 0 %}
    {% assign all_fulfilled = false %}
  {% endif %}
{% endfor %}

{% if all_fulfilled %}
  納品書
{% else %}
  納品書
{% endif %}

請求書ボタン

支払い方法がShopify Paymentsまたはスマホ決済かどうかを確認します。

※スマホ決済の名称はご自身の決済方法の文言に変更ください。

{% assign payment_gateway = order.gateway | downcase %}

{% if payment_gateway == 'shopify_payments' or payment_gateway contains 'スマホ決済' %}
  請求書
{% else %}
  請求書
{% endif %}

領収書ボタン

全額支払い済みかつすべての商品が発送済みかどうかを確認します。

{% assign all_fulfilled = true %}
{% for line_item in order.line_items %}
  {% if line_item.fulfillable_quantity > 0 %}
    {% assign all_fulfilled = false %}
  {% endif %}
{% endfor %}

{% if order.financial_status == 'paid' and all_fulfilled %}
  領収書
{% else %}
  領収書
{% endif %}

以上の調整で、ご希望の内容になるかと思われます。

実際の使用時は検証の上ご利用ください。

ご参考まで。

(キュー小坂)

現在の状況について補足します。

上記のLiquidによる方法は、テーマの旧カスタマーアカウント用テンプレートを編集するものです。そのため、旧カスタマーアカウントでのみ動作します。旧アカウントはShopifyにより非推奨となっており、新しいカスタマーアカウントではテーマのテンプレートが使われません。新しいアカウントに切り替えると、このボタンは表示されなくなります。

新しいアカウントで同様のボタンを表示するには、カスタマーアカウントUI拡張機能(アプリ、または自社開発)が必要です。

開示:私はOptimalify Customer Accountというアプリの開発に関わっています。新しいカスタマーアカウントの注文ページに、請求書PDFのダウンロードボタンを追加できます。適格請求書の登録番号(事業者が入力)も任意で記載できます。