# Shopify管理画面で「アイテムを削除」「数量を調整」した場合、ユーザー画面＞注文履歴画面に反映されない

**URL:** <https://community.shopify.com/t/shopify/11826>\
**Category:** 技術的なQ＆A\
**Created:** [April 27, 2020, 7:13am UTC](https://community.shopify.com/t/shopify/11826 "2020-04-27T07:13:34Z")\
**Posts on this page:** 11\
**Page:** 1

## AI-generated summary

Shopify管理画面で注文の「アイテムを削除」や「数量を調整」を行った場合、ユーザー側のマイページ(/account/)や注文履歴(/account/orders/)に変更が反映されない問題について議論されています。

**提案された解決策:**
- Liquidコードを使用して`order.refunds`や`refund_line_items`を参照し、返金・削除された商品を考慮した金額を表示する方法が提示されました
- `order.total_refunded_amount`や`order.transactions`を活用する代替案も提案されています
- カスタムアプリとapp proxiesを使ってAPIでデータを取得し、Liquidに反映させる高度なアプローチも紹介されました

**現状の課題:**
- 2022年3月時点で、公式ドキュメントから`order.refunds`が削除されており、一部のコードが動作しない可能性があります
- アイテム削除時に`order.total_refunded_amount`にデータが反映されないケースが報告されています
- OS 2.0への移行により、非公式Liquidが廃止された可能性が指摘されています

**新しい選択肢:**
Shopifyが提供する新しいログイン方法とUIに移行することで、Liquidに依存せず基本機能が提供される可能性があります。ただし、この問題に対するShopify公式の対応は明確ではなく、マーチャント側でのコード編集が必要な状況が続いています。

<div class="post-metadata">

**Author:** ![takahiron](https://avatars.discourse-cdn.com/v4/letter/t/2bfe46/32.png) [@takahiron](https://community.shopify.com/u/takahiron)\
**Post date:** [April 27, 2020, 7:13am UTC](https://community.shopify.com/t/shopify/11826/1 "2020-04-27T07:13:34Z")

</div>

・設定＞チェックアウト＞顧客アカウント＞アカウントを任意にする または アカウントを必要とする  
と設定した場合に、ユーザー画面で確認できる下記2つのテンプレートについて、  
不明点があり、質問を挙げさせていただきました。

/account/ マイページ  
/account/orders/ 注文履歴（詳細）

■質問内容  
上記2つのテンプレートに、注文の合計金額が表示されますが、  
・Shopify管理画面＞注文管理＞該当注文の詳細画面＞編集＞アイテムを削除  
または  
・Shopify管理画面＞注文管理＞該当注文の詳細画面＞編集＞数量を調整  
の操作した場合でも、ユーザー画面の上記2テンプレートに変更が反映されず、  
従来の内容のままとなっております。  
※管理画面側は、正しく変更されております。  
※テンプレートはDebutをカスタマイズせずに利用しております。

こちらテンプレートを調整し、改善できるなど  
方法がありましたらご教授いただければ幸いです。

---

<div class="post-metadata">

**Author:** ![junichiokamura](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/junichiokamura/32/299737_2.png) [@junichiokamura](https://community.shopify.com/u/junichiokamura)\
**Post date:** [April 27, 2020, 8:56am UTC](https://community.shopify.com/t/shopify/11826/2 "2020-04-27T08:56:22Z")

</div>

以下の修正は参考になりますでしょうか？

customer/order.liquidの最初に以下のコードを挿入

{% assign cancelled\_subtotal = 0 %}  
{% for refund in order.refunds %}  
{% for item in refund.refund\_line\_items %}  
{% assign cancelled\_subtotal = cancelled\_subtotal | plus:item.line\_item.price %}  
{% endfor %}  
{% endfor %}  
{% assign final\_cancelled\_with\_tax = cancelled\_subtotal| times:1.1 %}  
{% assign order\_subtotal\_with\_tax = order.subtotal\_price| times:1.1%}  
{% assign shipping\_with\_tax = order.shipping\_price| times:1.1%}  
{% if final\_cancelled\_with\_tax == order\_subtotal\_with\_tax %}  
{% assign final\_cancelled\_with\_tax = final\_cancelled\_with\_tax | plus:shipping\_with\_tax %}  
{% endif %}

{{ order.total\_price | money }} を {{ order.total\_price | minus:cancelled\_subtotal | money }} に置き換え。

---

<div class="post-metadata">

**Author:** ![ill\_support](https://avatars.discourse-cdn.com/v4/letter/i/73ab20/32.png) [@ill\_support](https://community.shopify.com/u/ill_support)\
**Post date:** [January 28, 2021, 5:56am UTC](https://community.shopify.com/t/shopify/11826/3 "2021-01-28T05:56:40Z")

</div>

こちら私も同様の事で困っておりまして、頂きましたタグを挿入した際には、

/account/orders/ 注文履歴（詳細）

の合計金額は変更が出来ました。

ただ、小計金額には、「アイテムを削除」「数量を調整」を考慮した金額が反映されておらず、

アイテムを削除した場合は、ユーザー側の注文履歴（詳細）からも削除したいのですが、

こちらは修正は可能なものでしょうか？

また、/account/

ページで表示される合計金額も「アイテムを削除」「数量を調整」を考慮した金額を表示したいのですが、可能でしょうか？

お手数をお掛けしますが、ご確認の程よろしくお願いします。

---

<div class="post-metadata">

**Author:** ![junichiokamura](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/junichiokamura/32/299737_2.png) [@junichiokamura](https://community.shopify.com/u/junichiokamura)\
**Post date:** [February 10, 2021, 9:06am UTC](https://community.shopify.com/t/shopify/11826/4 "2021-02-10T09:06:22Z")

</div>

Liquidの知識が必要になりますが、

[https://shopify.dev/docs/themes/liquid/reference/objects/order](https://shopify.dev/docs/themes/liquid/reference/objects/order)

> ただ、小計金額には、「アイテムを削除」「数量を調整」を考慮した金額が反映されておらず、

{% for refund in order.refunds %}  
{% for item in refund.refund\_line\_items %}

これを応用して、承継金額の表示部分も同じように修正する必要があると思います。

> ページで表示される合計金額も「アイテムを削除」「数量を調整」を考慮した金額を表示したいのですが、可能でしょうか？

Liquidのcustomerから同様のorderが参照できるので、同じ修正が可能かと思います。

[https://shopify.dev/docs/themes/liquid/reference/objects/customer#customer-orders](https://shopify.dev/docs/themes/liquid/reference/objects/customer#customer-orders)

---

<div class="post-metadata">

**Author:** ![Takuma](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/takuma/32/315167_2.png) [@Takuma](https://community.shopify.com/u/Takuma)\
**Post date:** [March 1, 2021, 12:48pm UTC](https://community.shopify.com/t/shopify/11826/5 "2021-03-01T12:48:04Z")

</div>

同じ現象で悩んだので、そういった明細に触るためのLIQUID例はこれ。

ご参考になれば。

{% for order in customer.orders %}

のループ内で、以下を入れれば返品や削除された商品を特定できます。

{% for refund in order.refunds %}  
{% for item in refund.refund\_line\_items %}  
{{ item.line\_item.title}}  
{% endfor %}  
{% endfor %}

POSTMANとかでOrderAPIの結果を見るとどこにどういった要素でデータが入ってるので探せます。

---

<div class="post-metadata">

**Author:** ![YasutakaNishii](https://avatars.discourse-cdn.com/v4/letter/y/e68b1a/32.png) [@YasutakaNishii](https://community.shopify.com/u/YasutakaNishii)\
**Post date:** [March 8, 2022, 11:38am UTC](https://community.shopify.com/t/shopify/11826/6 "2022-03-08T11:38:18Z")

</div>

こちらの方法は現時点 (2022/03) で実施することはできないのでしょうか。

上記コードを入力してブラウザを開くと、Internal Liquid Error と表示されます。

また、公式ドキュメントから order.refunds が消えております。

Cheat Sheet に refund で検索してもでてこないです。

[https://www.shopify.com/partners/shopify-cheat-sheet](https://www.shopify.com/partners/shopify-cheat-sheet)

---

<div class="post-metadata">

**Author:** ![junichiokamura](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/junichiokamura/32/299737_2.png) [@junichiokamura](https://community.shopify.com/u/junichiokamura)\
**Post date:** [March 8, 2022, 1:18pm UTC](https://community.shopify.com/t/shopify/11826/7 "2022-03-08T13:18:30Z")

</div>

元々refundsの情報は公式のLiquidドキュメントになかったかもですが、以下の、  
[https://shopify.dev/api/liquid/objects/order#order-total\_refunded\_amount](https://shopify.dev/api/liquid/objects/order#order-total_refunded_amount)

order.total\_refunded\_amountと、

order.transactionsの、  
[https://shopify.dev/api/liquid/objects/transaction](https://shopify.dev/api/liquid/objects/transaction)

transaction.kindやtransaction.statusから、返金額とその取引明細は出せると思います。  
ひょっとすると、2021年後半のOS 2.0 への移行によって、いくつかの非公式のLiquidが廃止になっている可能性もあります。

---

<div class="post-metadata">

**Author:** ![junichiokamura](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/junichiokamura/32/299737_2.png) [@junichiokamura](https://community.shopify.com/u/junichiokamura)\
**Post date:** [March 8, 2022, 1:31pm UTC](https://community.shopify.com/t/shopify/11826/8 "2022-03-08T13:31:57Z")

</div>

あとは、liquidのみでの解決ではなくなりますが、カスタムアプリ（パートナーダッシュボードから作成するタイプ）とapp proxiesの仕組みを使ってサーバーでAPIでデータを引いてそれをLiquidに反映する、といったアプローチも可能です。

[https://shopify.dev/apps/online-store/app-proxies](https://shopify.dev/apps/online-store/app-proxies)

ログインしているcustomerのidをapp proxies経由でサーバーに渡して、customer → order → refunds → refund line items と辿れば、元々のLiquidで参照できていたデータを取得できます。  
[https://shopify.dev/api/admin-graphql/2022-01/objects/RefundLineItem#fields](https://shopify.dev/api/admin-graphql/2022-01/objects/RefundLineItem#fields)

以下のようなマイページへのオーダー管理機能追加アプリは、同じようなことを内部でやっています。

[https://apps.shopify.com/orderify?locale=ja](https://apps.shopify.com/orderify?locale=ja)

app proxiesについては、以下でも解説しています。

[https://www.youtube.com/watch?v=w31mCsEWGhQ&list=PLkR3LRtxAZfqujVTfvuHGpNgVTdbrwJRK&index=12](https://www.youtube.com/watch?v=w31mCsEWGhQ&list=PLkR3LRtxAZfqujVTfvuHGpNgVTdbrwJRK&index=12)

---

<div class="post-metadata">

**Author:** ![YasutakaNishii](https://avatars.discourse-cdn.com/v4/letter/y/e68b1a/32.png) [@YasutakaNishii](https://community.shopify.com/u/YasutakaNishii)\
**Post date:** [March 9, 2022, 12:03am UTC](https://community.shopify.com/t/shopify/11826/9 "2022-03-09T00:03:16Z")

</div>

回答ありがとうございました。

アイテム追加して、削除するとorder.total\_refunded\_amount にはデータが反映されないようです。

（¥ 0 のまま）

一方で

- transaction.kind

- transaction.status

- transaction.amount

を利用すれば、最終金額は取れるのでそちらで対応したいと思います。

---

<div class="post-metadata">

**Author:** ![Anonymous\_60b47059533492517ffa8d07904e448b](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/anonymous_60b47059533492517ffa8d07904e448b/32/232580_2.png) [@Anonymous\_60b47059533492517ffa8d07904e448b](https://community.shopify.com/u/Anonymous_60b47059533492517ffa8d07904e448b)\
**Post date:** [May 2, 2024, 3:07pm UTC](https://community.shopify.com/t/shopify/11826/10 "2024-05-02T15:07:24Z")

</div>

同じ問題でこのページに辿り着きました。

素朴な疑問ですが、お客様から見たら単純な計算間違いであるこの問題にSopify側で対処されないのはなぜなのでしょうか。

マーチャントがリスクを負ってコード編集するのはおかしいと思います。

---

<div class="post-metadata">

**Author:** ![junichiokamura](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/junichiokamura/32/299737_2.png) [@junichiokamura](https://community.shopify.com/u/junichiokamura)\
**Post date:** [May 7, 2024, 7:08am UTC](https://community.shopify.com/t/shopify/11826/11 "2024-05-07T07:08:52Z")

</div>

マイページは、新しいログイン方法に従って、テーマのLiquidによる記述方式から、Shopifyの提供するUIに変わりました。可能であれば、そちらもお試しいただければと思います。  
[https://help.shopify.com/ja/manual/customers/customer-accounts/new-customer-accounts](https://help.shopify.com/ja/manual/customers/customer-accounts/new-customer-accounts)

Liquidによるマイページは、実際はShopify本体ではなくて、テーマの開発者の実装に依存する方法でしたが、新しいマイページは、基本的な機能はShopify側で提供されています。  
また、アプリによるカスタマイズも、Liquidとは違う方法で提供予定です。  
[https://shopify.dev/docs/apps/customer-accounts](https://shopify.dev/docs/apps/customer-accounts)
