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

# 條碼與 QR 碼

> 使用「條碼 / QR」區塊或 barcode 與 qr Liquid 篩選器，在單據中加入條碼與 QR 碼。

有了條碼與 QR 碼，您的團隊只要掃描就好，不必手動輸入：例如出貨單上的訂單編號、揀貨單上的每個 SKU，或提供給顧客的訂單狀態連結。Foliant 會以清晰的向量圖繪製這些碼，因此不論列印尺寸大小都能順利掃描，在預覽、列印出的單據和 PDF 中看起來也都一樣。

## 在視覺化編輯器中

新增一個 **條碼 / QR** 區塊（位於 **內容**），並設定：

* **類型**：**條碼（Code 128）** 或 **QR 碼**。
* **編碼內容**：**訂單名稱（#1042）**、**訂單編號（1042）**、**單據編號** 或 **自訂**。選擇 **自訂** 時，請填寫 **要編碼的文字**，可搭配訂單值，例如 `SO-{{ order_number }}`。

**商品表格** 也提供 **SKU 條碼** 和 **子類條碼** 欄位，**揀貨行** 區塊也能顯示訂單的條碼供掃描。

## 在程式碼中

### 條碼

```liquid theme={null}
{{ order_number | barcode }}
{{ line_item.sku | barcode }}
{{ line_item.variant.barcode | barcode: 'ean13' }}
{{ name | barcode: 'code128', 60, 12 }}
```

* 第一個選項是條碼類型。未指定時，預設為 Code 128。
* 另外兩個數字可設定列印的寬度與高度（公釐），例如貨運標籤使用 60 × 12 公釐。

支援的類型：`code128`、`code39`、`code39ext`、`code93`、`ean13`、`ean8`、`upca`、`upce`、`itf14`、`interleaved2of5`、`codabar` 和 `msi`。

### QR 碼

```liquid theme={null}
{{ order_status_url | qr }}
{{ order_status_url | qr: 'H', 120 }}
```

* 第一個選項是錯誤修正等級：`L`、`M`（預設）、`Q` 或 `H`。等級越高，碼受損時越能讀取，但圖案也會越密集。
* 第二個選項是尺寸（像素，預設為 96）。

## 小提醒

* 值為空白時不會繪製任何內容，因此沒有條碼的商品就不會顯示條碼。
* 如果值不符合條碼類型的格式（例如 EAN-13 中含有字母），會繪製一個標示原因的紅色小錯誤框，方便您在預覽中發現。
* **單據編號** 條碼在單據取得編號之前不會列印任何內容。
* `{{ order_status_url }}` 僅適用於線上訂單。

## 相關文章

* [區塊參考](https://foliant-help.iforiti.com/zh-Hant/template-editor/block-catalogue.md)
* [範本中的商品項目](https://foliant-help.iforiti.com/zh-Hant/template-editor/liquid-line-items.md)
* [範本中的單據編號](https://foliant-help.iforiti.com/zh-Hant/template-editor/liquid-document-numbers.md)
* [Liquid 篩選器](https://foliant-help.iforiti.com/zh-Hant/template-editor/liquid-filters.md)


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