> ## Documentation Index
> Fetch the complete documentation index at: https://foliant-help.iforiti.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 範本中的金額與貨幣

> Foliant 的 Liquid 中,金額值以分為單位。請使用金額篩選器,以訂單的貨幣或其他貨幣列印。

在 Foliant 的 Liquid 中,所有金額值都是以分為單位的整數:訂單總額 100.00 即為 `10000`。這與 Shopify Order Printer 相同,因此現有範本會列印出相同的金額。要列印金額時,請一律使用金額篩選器:它會除以 100 並加上貨幣。

## 金額篩選器

| 篩選器 | 範例 | 列印結果(商店格式 `${{amount}}`) |
| - | - | - |
| `money` | `{{ total_price \| money }}` | `$1,604.20` |
| `money_with_currency` | `{{ total_price \| money_with_currency }}` | `$1,604.20 USD` |
| `money_without_currency` | `{{ total_price \| money_without_currency }}` | `1,604.20` |
| `money_without_trailing_zeros` | `{{ 10000 \| money_without_trailing_zeros }}` | `$100` |
| `money_in` | `{{ amount \| money_in: 'EUR' }}` | 以您指定的貨幣顯示金額 |

* `money`、`money_with_currency`、`money_without_currency` 和 `money_without_trailing_zeros` 使用**訂單的貨幣**,因此以加幣付款的訂單會以 CAD 列印。
* `money_in` 會以訂單貨幣以外的貨幣列印金額,例如以您的本國貨幣列印增值稅:`{{ vat_reporting.tax | money_in: vat_reporting.currency }}`。

## 金額以哪種格式列印

範本的**數字格式**決定金額的顯示方式,您可在編輯器頂列或範本的設定頁面中設定:

| 數字格式 | 作用 |
| - | - |
| **商店貨幣格式** | 使用您在 Shopify 管理介面中設定的商店貨幣格式,與 Shopify Order Printer 相同。 |
| **文件語言的格式** | 依文件語言的寫法顯示金額,例如德文為 `1.234,56 €`。 |

`format_number` 一律使用文件語言的分隔符號:在德文文件中,`{{ 1234.5 | format_number: 2 }}` 會列印 `1.234,50`。

## 以分為單位進行計算

由於金額以分為單位,請先計算,最後再格式化:

```liquid theme={null}
{% assign balance = total_price | minus: total_paid %}
{% if balance > 0 %}
  {{ 'total_due' | t }}: {{ balance | money }}
{% endif %}
```

比較金額時也請使用分:`{% if total_price >= 10000 %}` 表示 100.00 以上。

## 小提醒

* 金額篩選器會依各貨幣列印正確的小數位數。有三位小數的貨幣(例如 KWD)會保留三位小數。
* 金額類型的中繼欄位不是以分為單位:它有 `value`(例如 `23.00`)和 `unit`(貨幣代碼)。請參閱[範本中的中繼欄位](https://foliant-help.iforiti.com/zh-Hant/template-editor/metafields.md)。
* 商品項目的價格已扣除商品項目折扣。整筆訂單的折扣在 `order_level_discounts` 中。請參閱[範本中的商品項目](https://foliant-help.iforiti.com/zh-Hant/template-editor/liquid-line-items.md)。

## 相關文章

* [訂單物件與常用變數](https://foliant-help.iforiti.com/zh-Hant/template-editor/liquid-order-variables.md)
* [Liquid 篩選器](https://foliant-help.iforiti.com/zh-Hant/template-editor/liquid-filters.md)
* [日期、語言與翻譯](https://foliant-help.iforiti.com/zh-Hant/template-editor/liquid-dates-and-languages.md)
* [Liquid 中的條件式內容](https://foliant-help.iforiti.com/zh-Hant/template-editor/liquid-conditional-content.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.