> ## 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/cn/template-editor/block-catalogue.md)
* [模板中的订单商品](https://foliant-help.iforiti.com/cn/template-editor/liquid-line-items.md)
* [模板中的单据编号](https://foliant-help.iforiti.com/cn/template-editor/liquid-document-numbers.md)
* [Liquid 过滤器](https://foliant-help.iforiti.com/cn/template-editor/liquid-filters.md)


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