> ## 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.

# 訂單物件與常用變數

> 範本用於訂單、顧客、地址、商店、運送、付款、退款和出貨的 Liquid 變數。

每份文件都是根據一筆訂單產生（批次範本則根據您選取的訂單）。在 Liquid 中，您可以直接使用訂單的欄位，例如 `{{ name }}`，也可以透過 `order` 使用，例如 `{{ order.name }}`。兩種寫法效果相同。這些變數沿用 Shopify Order Printer 的變數，因此大多數 Order Printer 範本可直接在 Foliant 中使用。

程式碼編輯器中的 **Liquid 變數**分頁列出所有變數，並提供搜尋功能。本文介紹您最常用的變數。金額以分為單位；請參閱[範本中的金額與幣別](https://foliant-help.iforiti.com/zh-Hant/template-editor/liquid-money-and-currency.md)。

## 訂單

| 變數 | 輸出內容 |
| - | - |
| `{{ order_name }}` 或 `{{ name }}` | 訂單名稱，含 #（`#1042`） |
| `{{ order_number }}` | 訂單編號（`1042`） |
| `{{ id }}` | 訂單 ID |
| `{{ po_number }}` | 採購單編號 |
| `{{ date }}` 或 `{{ created_at }}` | 下單時間。請使用 `date` 篩選器設定格式。 |
| `{{ processed_at }}`、`{{ updated_at }}`、`{{ cancelled_at }}`、`{{ closed_at }}` | 其他訂單日期 |
| `{{ completed_at }}` | 草稿訂單完成的時間 |
| `{{ financial_status }}` | 付款狀態，例如 `paid`、`pending` 或 `partially_refunded` |
| `{{ fulfillment_status }}` | 出貨狀態，例如 `unfulfilled` 或 `fulfilled` |
| `{{ note }}` | 訂單備註 |
| `{{ tags }}` | 訂單標籤（為清單：請用 `{% for tag in tags %}` 逐一處理） |
| `{{ email }}` | 訂單的電子郵件 |
| `{{ customer_locale }}` | 顧客購物時使用的語言 |
| `{{ order_status_url }}` | 訂單狀態頁面連結（線上訂單） |
| `{{ total_items }}` 或 `{{ item_count }}` | 品項數量 |
| `{{ total_weight }}` | 總重量；`{{ total_weight_in_grams \| weight_with_unit }}` 會加上單位 |
| `{{ order_currency }}` 或 `{{ currency }}` | 訂單的幣別代碼 |
| `{% if pickup_in_store? %}…{% endif %}` | 訂單是否為門市取貨 |
| `{{ location.name }}` | POS 地點（POS 訂單），另有 `address1`、`city`、`zip`、`country`、`phone`… |

## 總計

請使用金額篩選器輸出總計，例如 `{{ total_price | money }}`。

| 變數 | 說明 |
| - | - |
| `subtotal_price` | 小計 |
| `shipping_price` | 運費 |
| `total_discounts` | 所有折扣 |
| `order_level_discounts` | 整筆訂單的折扣（不含在品項價格中） |
| `total_tax` | 稅金 |
| `total_line_items_tax`、`total_shipping_tax` | 品項稅金，以及運費稅金 |
| `total_duties` | 關稅 |
| `total_price` | 訂單總額 |
| `total_paid` | 已付款金額 |
| `total_refunds` | 已退款金額 |
| `total_gift_cards` | 以禮品卡支付的金額 |

另外也可使用 `current_subtotal_price`、`current_total_discounts`、`current_total_tax` 和 `current_total_price`。

## 顧客與地址

| 變數 | 輸出內容 |
| - | - |
| `{{ customer.name }}`、`{{ customer.first_name }}`、`{{ customer.last_name }}` | 顧客姓名 |
| `{{ customer.email }}`、`{{ customer.phone }}` | 聯絡資訊 |
| `{{ customer.note }}` | 顧客備註 |
| `{{ customer.tags }}` | 顧客標籤 |
| `{{ customer.total_spent \| money }}` | 顧客的消費總額 |
| `{% if customer.tax_exempt %}` | 顧客是否免稅 |
| `{{ shipping_address \| format_address }}` | 運送地址，以換行排版 |
| `{{ billing_address \| format_address }}` | 帳單地址 |

每個地址（`shipping_address`、`billing_address` 和 `customer.default_address`）都有 `name`、`first_name`、`last_name`、`company`、`address1`、`address2`、`street`、`city`、`province`、`province_code`、`zip`、`country`、`country_code`、`phone` 和 `city_province_zip`。`{% if shipping_address.member_of_eu %}` 可檢查該國家是否屬於歐盟。

## 您的商店

| 變數 | 輸出內容 |
| - | - |
| `{{ shop.name }}` 或 `{{ shop_name }}` | 您的商店名稱 |
| `{{ shop.email }}`、`{{ shop.phone }}`、`{{ shop.domain }}` | 聯絡資訊 |
| `{{ shop.address1 }}`、`{{ shop.city }}`、`{{ shop.zip }}`、`{{ shop.country }}`… | 您在 Shopify 中設定的地址 |
| `{{ shop_logo_url }}`、`{{ shop_logo_width }}`、`{{ shop_accent_color }}` | 您在 **設定 › 品牌** 中設定的標誌和強調色 |
| `{{ shop.vat_number }}`、`{{ shop.eori }}` | 您在 **設定 › 稅務與法律** 中設定的加值稅號碼和 EORI |
| `{{ seller.legal_lines \| join: ' · ' }}` | 您的法律資訊，每項一行，使用文件的語言 |

## 運送、付款和出貨

| 變數 | 輸出內容 |
| - | - |
| `{{ shipping_method.title }}` | 運送方式 |
| `{% for shipping_line in shipping_lines %}` | 每個運送項目：`title`、`code`、`price` |
| `{{ payment_method }}`、`{{ gateway }}` | 訂單的付款方式 |
| `{% for transaction in transactions %}` | 每筆交易：`amount`、`kind`、`status`、`gateway`、`created_at` |
| `{% for tax_line in tax_lines %}` | 每項稅金：`title`、`rate`、`price` |
| `{% for discount in discounts %}` | 每項折扣：`code`、`amount`、`savings` |
| `{% for fulfillment in fulfillments %}` | 每筆出貨：`tracking_number`、`tracking_company`、`created_at` |
| `{{ latest_fulfillment }}` | 最近一筆出貨 |
| `{% for refund in refunds %}` | 每筆退款：`created_at`、`note`、`subtotal`、`total_tax`、`total`、`refund_line_items` |
| `{{ latest_refund }}` | 最近一筆退款（貸項憑單） |
| `{{ payment_terms.due_in_days }}` | 付款條件（B2B 和草稿訂單），另有 `payment_schedules` 和 `current_payment_schedule.due_at` |

## 範例

```liquid theme={null}
<h1>{{ 'titles.invoice' | t }} {{ order_name }}</h1>
<p>{{ created_at | date: '%d %B %Y' }}</p>
<p>{{ shipping_address | format_address }}</p>
<p>{{ 'total' | t }}: {{ total_price | money }}</p>
{% if note != blank %}<p>{{ note | escape }}</p>{% endif %}
```

## 小提醒

* 空值不會輸出任何內容。若沒有值時想省略標籤，請使用 `{% if … != blank %}`。
* 適用於所有選取訂單的範本會使用 `orders`（以 `{% for order in orders %}` 逐一處理）、`batch` 和 `pick_list`，而非單筆訂單。請參閱 **Liquid 變數**分頁中的 **批次範本** 區段。
* 若是加值稅發票，請參閱參考資料中的 **加值稅** 區段：`tax_breakdown`、`buyer.vat_number`、`{% include 'vat_breakdown' %}` 和 `{% include 'legal_notes' %}`。另請參閱[稅務與法律](https://foliant-help.iforiti.com/zh-Hant/tax-and-legal.md)。

## 相關文章

* [範本中的品項](https://foliant-help.iforiti.com/zh-Hant/template-editor/liquid-line-items.md)
* [範本中的金額與幣別](https://foliant-help.iforiti.com/zh-Hant/template-editor/liquid-money-and-currency.md)
* [Liquid 篩選器](https://foliant-help.iforiti.com/zh-Hant/template-editor/liquid-filters.md)
* [編輯範本程式碼](https://foliant-help.iforiti.com/zh-Hant/template-editor/code-editor.md)


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