sabkai
1
現在、shopfiy標準の明細書をカスタマイズして使用しています。(以下参考サイト)
https://rewired.cloud/shopify-packing-slip-price-and-shipping/
上記カスタマイズだと、注文内容を修正した時に(商品売り切れによる削除等)、修正内容が反映されません。
素人ながら、商品明細を表示するfor文で"line_items_in_shipment"から"order.line_items"しているのが、影響しているのではと考えています。
何か解決方法はありますでしょうか?
また、アプリの使用は今のところ考えていないです。
ご教授よろしくお願いいたします。
Qcoltd
2
@sabkai 様
興味があり調査してみました。
おっしゃる通り、
"line_items_in_shipment"から"order.line_items"に変更すると、
注文情報の編集が明細表に反映されないようです。
何か解決方法はありますでしょうか?
十分な動作検証をしていませんが、
例えば、商品の価格を表示したい場合は下記のようにされてはいかがでしょうか?
{% for line_item in line_items_in_shipment %}
{% for orderline_item in order.line_items %}
{% if line_item.sku == orderline_item.sku %}
{{ orderline_item.final_line_price | money }}
{% endif %}
{% endfor %}
{% endfor %}
なお、
Shopify標準の明細表は一度表示してしまいますと、
明細表のテンプレートを更新しても、
その更新内容が反映されるまでに時間がかかりますので、
表示内容が変わらない場合はしばらく時間を置いてからお試しいただくか、
新たに注文を作成されてお試しいただくのが良いです。
ご参考まで。
(キュー田辺)
1 Like
Ogata
4
私も同じ問題に直面し調べたところ、下記記述でうまく動作しました。
元ネタは下記の投稿です。参考になりましたら幸いです。
https://community.shopify.com/post/2174406
{% for line_item in line_items_in_shipment %}
{% assign final_price = nil %}
{% assign line_name = line_item.title %}
{% if line_item.variant_title != blank %}
{% assign line_name = line_name | append: " - " | append: line_item.variant_title %}
{% endif %}
{% for item in order.line_items %}
{% assign order_name = item.title %}
{% if order_name == line_name %}
{% assign final_price = item.final_price %}
{% endif %}
{% endfor %}
{% if final_price %}
{{ final_price | money }}
{% endif %}
sabkai1
5
Ogata様
ご返事が遅くなり申し訳ありません。
転記していただいたコードをそのままコピーしたのですが、上手く動作しませんでした。
原因がわかりましたら、教えてもらえないでしょうか?
よろしくお願いいたします
Ogata
6
こちらでカスタマイズしたソース全文をお伝えしますね。
ソース上部にロゴURLを挿入しているので、その部分は任意のものに変更してください。
今後のShopifyアップデート等で不具合を起こす可能性はございますので、あくまでも自己責任でご利用いただきますよう、お願いします。
注文番号 {{ order.name }}
{% if order.po_number != blank %}
注文書番号 #{{ order.po_number }}
{% endif %}
{{ order.created_at | date: format: "date" }}
{% if delivery_method.instructions != blank %}
お届け先
{% else %}
お届け先
{% endif %}
{% if shipping_address != blank %}
{{ shipping_address.name }} 様
{% if shipping_address.company != blank %}
{{ shipping_address.company }}
{% endif %}
{% if shipping_address.zip != blank %}
{{ shipping_address.zip }}
{% endif %}
{% if shipping_address.province != blank %}
{{ shipping_address.province }}
{% endif %}
{% if shipping_address.city != blank %}
{{ shipping_address.city }}
{% endif %}
{{ shipping_address.address1 }}
{% if shipping_address.address2 != blank %}
{{ shipping_address.address2 }}
{% endif %}
{% if shipping_address.phone != blank %}
{{ shipping_address.phone }}
{% endif %}
{% else %}
配送先住所がありません
{% endif %}
請求先
{% if billing_address != blank %}
{{ billing_address.name }} 様
{% if billing_address.company != blank %}
{{ billing_address.company }}
{% endif %}
{% if billing_address.zip != blank %}
{{ billing_address.zip }}
{% endif %}
{% if shipping_address.province != blank %}
{{ billing_address.province }}
{% endif %}
{% if shipping_address.city != blank %}
{{ billing_address.city }}
{% endif %}
{{ billing_address.address1 }}
{% if billing_address.address2 != blank %}
{{ billing_address.address2 }}
{% endif %}
{% else %}
請求先住所がありません
{% endif %}
---
商品
金額 / 数量
{% comment %}
To adjust the size of line item images, change desired_image_size.
The other variables make sure your images print at high quality.
{% endcomment %}
{% assign desired_image_size = 58 %}
{% assign resolution_adjusted_size = desired_image_size | times: 300 | divided_by: 72 | ceil %}
{% capture effective_image_dimensions %}
{{ resolution_adjusted_size }}x{{ resolution_adjusted_size }}
{% endcapture %}
{% for line_item in line_items_in_shipment %}
{{ line_item.title }}
{% if line_item.variant_title != blank %}
{{ line_item.variant_title }}
{% endif %}
{% if line_item.sku != blank %}
{{ line_item.sku }}
{% endif %}
{% for group in line_item.groups %}
{{ group.title }}の一部
{% endfor %}
{% assign final_price = nil %}
{% assign line_name = line_item.title %} {% if line_item.variant_title != blank %} {% assign line_name = line_name | append: " - " | append: line_item.variant_title %} {% endif %} {% for item in order.line_items %} {% assign order_name = item.title %}
{% if order_name == line_name %}
{% assign final_price = item.final_price %}
{% endif %}
{% endfor %}
{% if final_price %}
{{ final_price | money }}
{% endif %}
/
{{ line_item.quantity }}
{% endfor %}
{% unless includes_all_line_items_in_order %}
---
この発送に含まれていない商品があります。(キャンセル商品含む)
{% endunless %}
---
小計:{{ order.subtotal_price | money }}
(うち消費税){{ order.tax_price | money }}
送料:{{ order.shipping_price | money }}
{%- if order.total_discount -%}
割引:-{{ order.total_discount | money }}
{%- endif -%}
合計金額:{{ order.total_price | money }}
{% if order.note != blank %}
メモ
{{ order.note }}
{% endif %}
{% if delivery_method.instructions != blank %}
配達指示
{{ delivery_method.instructions }}
{% endif %}
ご不明点がございましたら{{ shop.email }}までお問い合わせください。
<strong>
{{ shop.name }}
</strong>
{{ shop.domain }}