Liquid、JavaScriptなどに関する質問
order printerで受注明細を印刷しています。
割引クーポン名またはクーポンコードを入れたいのですが、
{{ discount.code }} もしくは {{ discount.title }}
この2つを入力しても、表示されません。
どこが間違ってるのかご教授お願いいたします。
***************************************
<style>
.printer-preview-content h1 {
font-size: 140%;
margin: 20px 0 0 0;
}
.printer-preview-content h2 {
font-size: 100%;
}
.printer-preview-content h3 {
font-size: 90%;
}
.printer-preview-content li{
list-style:none;
}
p {
margin: 0;
}
header {
display: flex;
justify-content: space-between;
border: solid 1px #000;
}
.header_in {
padding: 10px;
}
.order_item {
border: solid 1px #000;
}
.transactions {
border: solid 1px #000;
}
.shop {
padding: 10px;
background-color: #dddddd;
text-align: right;
}
table .item {
width: 100%;
}
.printer-preview-content th {
width: -webkit-fill-available;
background-color: #eaeaea;
}
table,th,td {
border: 1px solid #bbb;
padding: 0 20px;
}
.order_in {
margin: 0 0 20px;
border: solid 1px #000;
}
.billing ,.shipping {
width: calc(100% / 2 - 10px);
padding: 10px;
border: solid 1px #000;
}
.pay {
display: flex;
margin: 0 0 10px;
padding: 0 0 0 10px;
border: solid 1px #000;
}
.address {
display: flex;
margin: 0 0 20px;
justify-content: space-between;
}
.remarks {
padding: 10px;
border: solid 1px #000;
}
</style>
<header>
<div class="header_in">
<p>ご注文日{{ processed_at }}</p>
<p>ご注文番号{{ order_name }}</p>
</div>
<!-- ショップ情報 -->
<div class="shop">
<p>ショップ:{{ shop_name }}</p>
〒{{ shop.zip | upcase }}
{{ shop.province | replace: 'Aichi', '愛知県' | replace: 'Akita', '秋田 県' | replace: 'Aomori', '青森県' | replace: 'Chiba', '千葉県' | replace: 'Ehime', '愛 媛県' | replace: 'Fukui', '福井県' | replace: 'Fukuoka', '福岡県' | replace: 'Fukushima', '福島県' | replace: 'Gifu', '岐阜県' | replace: 'Gunma', '群馬県' | replace: 'Hiroshima', '広島県' | replace: 'Hokkaidō', '北海道' | replace: 'Hyōgo', '兵庫県' | replace: 'Ibaraki', '茨城県' | replace: 'Ishikawa', '石川県' | replace: 'Iwate', '岩手県' | replace: 'Kagawa', '香川県' | replace: 'Yamanashi', '山梨県' | replace: 'Yamaguchi', '山口県' | replace: 'Kōchi', '高知県' | replace: 'Kumamoto', '熊本県' | replace: 'Kyōto', '京都府' | replace: 'Mie', '三重県' | replace: 'Yamagata', '山形県' | replace: 'Miyazaki', '宮崎県' | replace: 'Nagano', '長野県' | replace: 'Nagasaki', '長崎県' | replace: 'Nara', '奈良県' | replace: 'Niigata', '新潟県' | replace: 'Ōita', '大分県' | replace: 'Okayama', '岡山県' | replace: 'Okinawa', '沖縄県' | replace: 'Ōsaka', '大阪府' | replace: 'Saga', '佐賀 県' | replace: 'Saitama', '埼玉県' | replace: 'Shiga', '滋賀県' | replace: 'Shimane', '島根県' | replace: 'Shizuoka', '静岡県' | replace: 'Tochigi', '栃木県' | replace: 'Tokushima', '徳島県' | replace: 'Tottori', '鳥取県' | replace: 'Toyama', '富山県' | replace: 'Tōkyō', '東京都' | replace: 'Miyagi', '宮城県' | replace: 'Wakayama', '和 歌山県' | replace: 'Kanagawa', '神奈川県' | replace: 'Kagoshima', '鹿児島県' }}
{{ shop.city }}
{{ shop.address }}
{{ shop.address2 }}
</div>
</header>
<h1>ご注文詳細</h1>
<div class="pay">
<h2>支払い方法</h2>
{% for transaction in transactions %}
{% if transaction.status != "failure" and transaction.status != "error" %}
{% if transaction.kind == "authorization" or transaction.kind == "sale" %}
{% if transaction.payment_details.credit_card_number %}
<p>{{ transaction.gateway | payment_method }}:{{ transaction.payment_details.credit_card_company }}:{{ transaction.payment_details.credit_card_number }}{% break %}</p>
{% else %}
<p>{{ transaction.gateway | payment_method }}:{{ transaction.gateway }}{% break %}</p>
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
</div>
<div class="order_in">
{% for line_item in line_items %}
<table style="width: 100%;">
<tr>
<th style="width:73%;">商品名</th>
<th style="width:10%;">数量</th>
<th style="width:10%;">単価 (税込)</th>
</tr>
<tr>
<td style="text-align: left;">
<!-- 品番 -->
{% if line_item.sku != blank %}【{{ line_item.sku }}】{% endif %}
<!-- 商品名 -->
{{ line_item.title }}</td>
<td style="text-align: center;">{{ line_item.quantity }}</td>
<td style="text-align: right;">{{ line_item.original_price | money }}</td>
</tr>
{% endfor %}
</table>
</div>
<h2>お支払い内訳</h2>
<div class="order_in">
<table style="width: 100%;">
<tr>
<th style="width:73%;">割引コード{{ discount.title }}</th>
<td style="width: 20%;text-align: right;">{{ total_discounts | money }}</td>
</tr>
<tr>
<th style="width:73%;">(内消費税)</th>
<td style="width: 20%;text-align: right;">{{ tax_price | money }}</td>
</tr>
<th style="width:73%;">送料(税込)</th>
<td style="width: 20%;text-align: right;">{{ shipping_price | money }}</td>
</tr>
<tr>
<th style="width:73%;">総合計(税込)</th>
<td style="width: 20%;text-align: right;">
{{ total_price | money }}
{% if total_paid != total_price %}
{% endif %}
</td>
</tr>
</table>
</div>
<div class="address">
<div class="billing">
<h2>注文者</h2>
<ul>
<!-- 注文者の住所 -->
<li>{{ billing_address | format_address }} </li>
<!-- 注文者の人のフルネーム -->
<li>{{ billing_address.last_name }}{{ billing_address.first_name }} </li>
<!-- 注文者電話番号 -->
<li>電話番号:{{ billing_address.phone }}</li>
</ul>
</div>
<div class="shipping">
<h2>お届け先</h2>
<!-- お届け先の住所 -->
<li>{{ shipping_address | format_address }} </li>
<!-- お届け先の人のフルネーム -->
<li>{{ shipping_address.last_name }}{{ shipping_address.first_name }} </li>
<!-- お届け先電話番号 -->
<li>電話番号:{{ shipping_address.phone }}</li>
</div>
</div>
<!-- 備考 -->
<div class="remarks">
<h2>備考</h2>
{{ note }}
</div>
<div class="remarks">
<!-- 配送方法 -->
{{ shipping_method.title }}
<!-- 配送希望日 -->
{% for attribute in attributes %}
{% if attribute.first == "配送希望日" %}
<h3>{{ attribute | first }}</h3>
<p>{{ attribute | last }}</p>
{% endif %}
{% endfor %}
<!-- 時間指定 -->
{% for attribute in attributes %}
{% if attribute.first == "配送希望時間" %}
<h3>{{ attribute | first }}</h3>
<p>{{ attribute | last }}</p>
{% endif %}
{% endfor %}
</div>
下記ではどうでしょうか?
{% for discount in discounts %}
{{ discount.code }}
{% endfor %}
複数のディスカウントが効いている場合に備えて、表示調整も必要かと思いますが、まず、上記がうまくいくかお試しいただくと良いかと思います。
ご参考まで。
(キュー田辺)
Shopify アカデミーの学習パスと認定スキルバッジExpanding Your Shopify Business Internationallyを活用して、国際的にビジネ...
By Shopify Feb 7, 2025Shopify アカデミーの学習パスB2B on Shopify:立ち上げとカスタマイズで卸売販売に進出しましょう。これら3つの無料コースは、ShopifyストアでB2B機能...
By Shopify Jan 31, 2025サポートの選択肢が増えていく中、最適となる選択の判断が難しくなっているかと存じます。今回は問題の解決に最適となるサポートの選択方法を、紹介させて頂きます。 選択肢のご紹介...
By Mirai Oct 6, 2024