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

# 訂單屬性與品項屬性

> 列印顧客在結帳時或商品頁面上填寫的自訂欄位，例如禮品留言、配送日期或刻字內容。

許多商店會向顧客收集額外資訊：在結帳時填寫的配送日期或禮品留言（訂單屬性，也稱為購物車屬性或備註屬性），或在商品頁面上填寫的刻字內容或字母組合圖案（品項屬性）。Shopify 會將這些資訊與訂單一起保存，您的範本可以將它們列印出來。

## 訂單屬性

`attributes` 存放訂單的自訂欄位，每個欄位都有名稱和值。

列印所有欄位：

```liquid theme={null}
{% for attribute in attributes %}
  <p><strong>{{ attribute.first | escape }}:</strong> {{ attribute.last | escape }}</p>
{% endfor %}
```

依名稱列印單一欄位，名稱須與訂單中的拼寫完全相同：

```liquid theme={null}
{% if attributes['Gift message'] != blank %}
  <p>{{ attributes['Gift message'] | escape }}</p>
{% endif %}
```

## 品項屬性

每個品項的 `properties` 存放該品項的自訂欄位。請在品項迴圈內列印：

```liquid theme={null}
{% for line_item in line_items %}
  {{ line_item.title }}
  {% for property in line_item.properties %}
    {% unless property.last == blank %}
      <br>{{ property.first | escape }}: {{ property.last | escape }}
    {% endunless %}
  {% endfor %}
{% endfor %}
```

`property.first` 是欄位名稱，`property.last` 是欄位值。

名稱以底線開頭的屬性（例如 `_bundle_id`）是用來隱藏的。若要略過這些屬性：

```liquid theme={null}
{% assign first_letter = property.first | slice: 0 %}
{% unless first_letter == '_' or property.last == blank %}
  {{ property.first | escape }}: {{ property.last | escape }}
{% endunless %}
```

## 在視覺化編輯器中

* **商品表格**：在 **列** 下勾選 **品項屬性（刻字、禮品留言…）**，即可在每個品項的標題下方列印其屬性。名稱以底線開頭的屬性及空白屬性不會列印。
* 訂單屬性：使用 **自訂 Liquid** 區塊，並套用上方的迴圈。

## 注意事項

* 請一律在顧客輸入的內容後加上 `| escape`，讓您列印出的內容以純文字呈現。
* 訂單屬性名稱會區分大小寫：`attributes['gift message']` 和 `attributes['Gift message']` 是不同的。
* 存放在中繼欄位而非屬性中的資料，列印方式不同。請參閱[範本中的中繼欄位](https://foliant-help.iforiti.com/zh-Hant/template-editor/metafields.md)。
* 透過 Bold Product Options 或 Infinite Options 做出的選擇也屬於訂單項目屬性；其付費加購項目可以列印在品項下方。請參閱 [商品選項應用程式（Bold、Infinite Options）](https://foliant-help.iforiti.com/zh-Hant/templates/product-options-apps.md)。

## 相關文章

* [範本中的品項](https://foliant-help.iforiti.com/zh-Hant/template-editor/liquid-line-items.md)
* [範本中的中繼欄位](https://foliant-help.iforiti.com/zh-Hant/template-editor/metafields.md)
* [Liquid 中的條件式內容](https://foliant-help.iforiti.com/zh-Hant/template-editor/liquid-conditional-content.md)
* [區塊參考](https://foliant-help.iforiti.com/zh-Hant/template-editor/block-catalogue.md)


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