> ## 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/cn/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 }}` | 您在 **设置 › 品牌** 中设置的 logo 和强调色 |
| `{{ 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/cn/tax-and-legal.md)。

## 相关文章

* [模板中的商品行](https://foliant-help.iforiti.com/cn/template-editor/liquid-line-items.md)
* [模板中的金额和货币](https://foliant-help.iforiti.com/cn/template-editor/liquid-money-and-currency.md)
* [Liquid 过滤器](https://foliant-help.iforiti.com/cn/template-editor/liquid-filters.md)
* [编辑模板代码](https://foliant-help.iforiti.com/cn/template-editor/code-editor.md)


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