通知变量参考

从商店发出的通知是使用 Liquid 呈现的。Liquid 是 Shopify 的简单易用的编程语言。我们在模板商店中提供的模板也是采用这种编程语言构建的。

若要编辑从商店发送的通知,您可以对您的通知模板进行基本的自定义

若要获取有关更高级更改的帮助或要更改自定义通知模板,您可以访问我们论坛上的社区,也可以聘请一位 Shopify 专家来为您完成自定义工作。详细了解如何聘请 Shopify 专家

以下是您可以从 Shopify 后台自定义的 Liquid 通知模板的列表:

  • 弃单
  • 联系客户
  • 客户账户邀请
  • 客户账户欢迎
  • 客户账户密码重置
  • 草稿订单发票
  • 发货请求
  • 礼品卡已创建
  • 新订单
  • 新订单(移动版)
  • 订单发票
  • 订单已取消
  • 订单确认
  • POS 和移动收据
  • 订单退款
  • 发货确认
  • 发货更新信息

Shopify 后台中的所有模板都可以访问相应订单的属性。

订单属性

一个订单的许多属性可以直接通过使用 Liquid、模板和自定义脚本获取。

以下模板中提供订单的属性:

  • 订单确认
  • 新订单
  • 新订单(移动版)
  • 订单发票
  • 发货确认
  • 发货更新信息
  • 自定义脚本
  • 发货请求
订单属性的描述
属性 描述
id

订单在系统范围内的唯一 ID,供内部使用。使用以下示例在商店的后台部分生成指向订单的链接。例如,在新订单模板中,您可以添加以下代码:

<a href="{{ shop.url }}/admin/orders/{{ id }}">查看订单</a>
email
与订单关联的电子邮件。
name

通常是一个 # 符号,后跟 order_number

示例:#1004

order_name
与名称相同。
order_number

订单在商店中的唯一编号,没有 # 前缀,店主也不会在商店偏好设置中为订单 ID 添加任何前缀或后缀。

例如:1004

created_at

客户创建订单的日期和时间。您可以使用日期筛选器对其进行格式化。

示例:2009-05-30T17:43:51+02:00

payment_terms

付款期限指定了订单的应付款日期。

了解如何向订单发票中添加付款期限

有关详细信息,请参阅 payment_terms 的 Liquid 参考。

tags 返回所有订单标签的数组。标签按字母顺序返回。有关详细信息,请参阅我们的 Liquid 参考文档
transactions 返回订单中交易的数组。
tax_price
订单中所有商品的综合税金。
tax_lines

按税种划分的税金:

{% for tax_line in tax_lines %} {{ tax_line.title }} ({{ tax_line.rate_percentage }}%) : {{ tax_line.price | money_with_currency }} {% endfor %}
tax_line.title

税金的名称。

示例:QST 或 VAT

tax_line.price
金额。
tax_line.rate
费率。如果是 17.5%,则将返回 0.175。
tax_line.rate_percentage
采用可人工读取形式的税率。如果费率为 0.175,它将返回 17.5。
customer
包含 customer 输出属性的 Customer 对象。
billing_address
账单地址
billing_address.first_name
客户的名字。
billing_address.last_name
客户的姓氏。
billing_address.company
计费公司名称。
billing_address.phone
账单地址中的电话号码。
shop.name
您的商店名称。
shop.phone
您商店的电话号码。
subtotal_price
扣除任何订单项目折扣或购物车折扣后的订单项目价格总额。小计不含税费(除非税费已包含在价格中)、运费或小费。
discounts
折扣列表。
discounts_amount

所有折扣适用的折扣金额。

示例:+5.00 美元

discounts_savings

使用所有折扣所节省的金额。

例如:-5.00 美元

total_price

订单的总价(小计 + 运费 - 运费折扣 + 税金)。

financial_status
当前的付款状态。可能的属性值包括:空、待付款已授权已付款已作废已退款
requires_shipping
(布尔值)如果订单中至少有一件产品需要发货,则返回 true。
shipping_method.title

运费名称。

示例:标准运费

shipping_method.price

包括所有运费折扣的运费。

示例:{{ shipping_method.price | money }}

shipping_price

运费。

示例:{{ shipping_price | money }}

shipping_address
收货地址
shipping_address.first_name
收货地址中的名字。
shipping_address.company
收货地址中的公司名称。
shipping_address.phone
发货地址的电话号码。
line_items
订单中所有订单项目的列表。
item_count
所有商品的数量总和。
fulfillment_status
订单的当前发货状态。可能的属性值包括:未发货部分发货已发货
note
附加至订单的备注。该备注可以从客户处获取以及/或者在您的后台界面的订单详情页中编辑。
attributes

附加到订单的任何属性

示例:{{ attributes.gift-note }}

referring_site

包含将客户引导至您商店的推荐来源的 URL。

示例:https://www.google.com/?s=great+products

landing_site

包含客户使用的登陆网站的路径。这是客户访问商店时看到的首个页面。

示例:/products/great-product?ref=my-tracking-token

landing_site_ref

查看登陆网站并从中提取引用参数。引用参数可以为:refsourcer

如果 landing_site/products/great-product?ref=my-tracking-token,则 landing_site_ref 将为 my-tracking-token。如果您的 ref 等于某个特定值,则您可以执行某个特定操作:

{% if landing_site_ref == 'my-tracking-token' %} My action... {% endif %}
cancelled
(布尔值)如果订单已被取消,则返回 true。
cancelled_at
订单取消的时间。
cancel_reason
取消订单时所选择的原因。可以为以下原因之一:库存客户已拒绝欺诈其他
has_high_risks?
(已弃用)

如果订单存在高风险,则返回 true

unique_gateways

返回订单上唯一支付服务提供商的列表。例如,如果有人使用 Visa、Mastercard 和现金付款,则返回的列表为 shopify_payments, cash

location (POS only)

显示订单的实际地点。此处列出了一些可用的地点属性。您可以在后台的“地点”区域配置地点。

order_status_url

返回指向此订单的订单状态页面的链接。

fulfilled_line_items
(已弃用)
已发货的订单项列表。
unfulfilled_line_items
(已弃用)
尚未全部发货的订单项目的列表。
b2b?

Returns true if the order is a B2B order. Use the property with B2B variables to display relevant information, such as the company name, company location, and address in emails. For example, on B2B orders, you might add a header to a template with the following information:

{% if b2b? %}
        <p> Customer: {{ customer.name }}
        <p> Company: {{ company.name }}
        <p> Location: {{ company_location.name }}
      {endif%}
      
company

The company that you’re selling to on a B2B order.

company.name

The name of the company on a B2B order.

company.id

The ID of the company on a B2B order.

company_location

The location of the company on a B2B order. A company that buys from you can have more than one location.

company_location.name

The name of the company location on a B2B order.

company_location.id

The ID number of the company location on a B2B order.

company_location.shipping_address

The shipping addressof the company location on a B2B order.

company_location.billing_address

The billing addressof the company location on a B2B order.

Draft order properties

Draft order properties are available on the Draft Order Invoice email template, which notifies your customers about outstanding invoices.

Description of draft order properties
Property Description
id
A unique ID of the draft order for internal use.
invoice_url
A link the customer can follow to pay for the invoice using Shopify's secure checkout.
reserve_inventory_until

The date and time the line items in the draft are reserved until, for example, 2015-05-30T17:43:51+02:00.

You can format dates using the Liquid date filter.

user
The last staff who modified the draft order.
user.name
The name of the last staff who modified the draft order.
user.email
The email address of the last staff who modified the draft order.
email
The email address associated with the draft order.
name
The unique number of the draft order, prefixed by a number sign #.
number
The unique number of the draft order without the order prefix or suffix.
created_at

The date and time the customer created the draft order, for example, 2009-05-30T17:43:51+02:00.

You can format dates using the Liquid date filter.

tags Returns an array of all of the order's tags. The tags are returned in alphabetical order. Please see our Liquid reference documentation for more details.
tax_price
The combined taxes of all the items in the draft order.
tax_lines

Taxes broken up by type of tax:

{% for tax_line in tax_lines %}
{{ tax_line.title }} ({{ tax_line.rate_percentage }}%) : {{ tax_line.price | money_with_currency }}
{% endfor %}
tax_line.title

The name of the tax.

Examples: QST or VAT

tax_line.price
The tax amount.
tax_line.rate
The tax rate in decimal form. For example, a tax rate of 17.5% will return 0.175.
tax_line.rate_percentage
The tax rate in percentage form. For example, a rate of 0.175 will return 17.5.
customer
Customer object containing the attributes of the customer output.
billing_address
The billing address for the draft order.
billing_address.first_name
The customer's first name.
billing_address.last_name
The customer's last name.
billing_address.company
The company name in the billing address.
billing_address.phone
The phone number in the billing address.
shop.name
The name of your store.
shop.phone
Your store's phone number.
subtotal_price
Sum of the draft order's line-item prices after any line-item discount or cart discount has been deducted. The subtotal doesn't include taxes (unless taxes are included in the prices) or shipping costs.
discounts
A list of discounts.
discounts_amount

Amount of the discount applied by all discounts.

Example: +$5.00

discounts_savings

Amount of the savings caused by all discounts.

Example: -$5.00

total_price
The total price of the order (subtotal + shipping cost - shipping discount + tax).
requires_shipping
Returns true if there is at least one item in the draft order that requires shipping. Returns false if no items in the draft order require shipping.
shipping_method.title

The Shipping rate name.

Example: Standard Shipping

shipping_method.price
The price of the shipping method. Returns the same information as shipping_price.
shipping_price

The shipping price.

You can format this amount using Liquid money filters.

shipping_address

The shipping address.

Note: Unlike in regular orders, a draft order's shipping address may be incomplete.

shipping_address.first_name
The first name for the shipping address.
shipping_address.company
The company name in the shipping address.
shipping_address.phone
The phone number in the shipping address.
line_items
A list of all line items in the draft order.
item_count
A sum of all the item quantities in the draft order.
note
The note attached to the draft order. The note can be obtained from the customer and also edited in the draft order detail screen in your Shopify admin.
location

The physical location of the order. There are several location properties available.

You can configure locations in the Locations page of your Shopify admin.

b2b?

Returns true if the order is a B2B order. Use the property with B2B variables to display relevant information, such as the company name, company location, and address in emails. For example, on B2B orders, you might add a header to a template with the following information:

{% if b2b? %}
        <p> Customer: {{ customer.name }}
        <p> Company: {{ company.name }}
        <p> Location: {{ company_location.name }}
      {endif%}
      
company

The company that you’re selling to on a B2B order.

company.name

The name of the company on a B2B order.

company.id

The ID of the company on a B2B order.

company_location

The location of the company on a B2B order. A company that buys from you can have more than one location.

company_location.name

The name of the company location on a B2B order.

company_location.id

The ID number of the company location on a B2B order.

company_location.shipping_address

The shipping addressof the company location on a B2B order.

company_location.billing_address

The billing addressof the company location on a B2B order.

Line item properties

Each line in the list of line_items or subtotal_line_items has the following properties.

Description of line item properties
Property Description
line.applied_discounts
(POS and draft orders only)
List of discounts applied to this item (each discount has the title, code, amount, savings and type properties).
line.custom
(Draft orders only)
(boolean) Returns true if the item is a custom line item for a draft order.
line.grams
Weight of a single item.
line.image
Returns the URL of the image associated with this line item. You can also use the img_url filter to get specific image sizes, for example {{ line.image | img_url: 'small' }}
line.line_price
The price multiplied by the quantity for that item.
line.original_line_price
The combined price of the quantity of items included in the line, before discounts were applied.
line.final_line_price
The combined price of all the items in the line item, including all line level discount amounts.
line.price
The price for a single item.
line.product.metafields

The Metafields at the product level. Use the following syntax:

line.product.metafields.NAMESPACE.KEY

line.product.title
The name of the product.
line.product.vendor
The vendor for the item.
line.properties
Returns an array of custom information for an item. Line item properties are specified by the customer on the product page, before adding a product to the cart.
line.quantity
Quantity for that item.
line.requires_shipping
(boolean) Returns true if the variant for the item has the checkbox This is a physical product checked on the product page.
line.selling_plan_allocation
Returns a selling_plan_allocation object, which describes how a selling plan such as a subscription impacts the line item.
line.taxable
(boolean) Returns true if the variant for the item has the checkbox 'Charge taxes on this product' checked on the product page.
line.title
The name of the product followed by a dash followed by the name of the variant. The variant name isn't included when it is “Default Title”.
line.url
The relative URL of the line item's variant. The relative URL doesn't include your store's root URL (mystore.myshopify.com).
line.line_item.variant.barcode
The barcode associated with the product variant.
line.variant.compare_at_price
The compare at price associated with the product variant.
line.variant.image
The image for the product variant. Only returns an image if there is a specific image assigned to the variant in the line item.
line.variant.metafields

The Metafields at the variant level. Use the following syntax:

line.variant.metafields.NAMESPACE.KEY

line.variant.sku
The SKU associated with the product variant.
line.variant.title

The variant's option values, joined by / characters.

Example: small / red

line.refunded.quantity 
      
(within refund notifications)

The quantity of an item to be refunded. You can use this property to add an identifier to refunded items in an order.

For example: {% if line.refunded_quantity > 0 %}Refunded line identifier{% endif %}

Refunds properties

These additional properties are available on the Refunds email template. This email template is used to notify your customers that a refund (complete or partial) has been applied to their order. You can use any variable available for the Order email notification template, in addition to the following variables:

Description of refunds properties
Property Description
amount
The amount of money refunded.
refund_line_items
A list of refund line items to be refunded.

Refund_line_item properties

Each refund_line in the list of refund_line_items has the following properties:

Description of refund line item properties
Property Description
refund_line.line_item
The line_item that is being refunded. This has access to all the line_item’s properties.
refund_line.quantity
The quantity of the line item to be refunded.

Fulfillment properties

These additional properties are available on the Shipping confirmation, Shipping update and Fulfillment request email templates.

The Shipping confirmation and Shipping update are used to notify your customers that some or all items in their order have been successfully fulfilled, or updated with new shipping information.

The Fulfillment request email template is used for any custom fulfillment service defined in your shop admin. To add a custom fulfillment service, go to Settings > Shipping and scroll down to Fulfillment/Dropshipping.

Description of fulfillment properties
Property Description
service_name
The name of the custom service as defined in the Settings > Shipping page. (Fulfillment request only)
fulfillment.estimated_delivery_at
An estimated delivery date based on the tracking number (if available) provided by one of the following carriers: USPS, FedEx, UPS, Canada Post (Canada only). This property is only available when carrier-calculated rates are in use.
fulfillment.fulfillment_line_items
A list of fulfillment line items to be fulfilled.
fulfillment.item_count
A sum of all the items' quantities. The total number of items being fulfilled.
fulfillment.requires_shipping
(boolean) Returns true if this fulfillment request requires shipping.
fulfillment.tracking_company
The company doing the tracking.
fulfillment.tracking_numbers
A list of tracking numbers.
fulfillment.tracking_urls
A list of tracking URLs.
items_to_fulfill
(deprecated)
A list of line items that are to be fulfilled by this particular custom fulfillment service. (Fulfillment request only)
items_to_fulfill_count
(deprecated)
The total number of items to be fulfilled by this request. (Fulfillment request only)

Fulfillment_line_item properties

Each fulfillment_line in the list of fulfillment_line_items has the following properties.

Description of fulfillment line item properties
Property Description
fulfillment_line.line_item
The line_item being fulfilled. This has access to all the line_item's properties.
fulfillment_line.quantity
The quantity of the line item that is being fulfilled.

Delivery properties

Description of delivery properties
Property Description
delivery_instructions
Local delivery information to share with the customer. This information is controlled by the Delivery information field in your local delivery settings.
consolidated_estimated_delivery_time
Order delivery dates information to share with the customer. This information is controlled by the Processing time setting that you set up in your Shipping and delivery page.

Discount properties

There are two types of discount properties.

discount_applications describe why and how an item was discounted.

discount_allocations describe how a particular discount affects a line item and how it reduces the price. You should use this property at the line item level.

You can combine these properties to display discount information at the line item or order level.

Example

This example checks if a discount has been applied to the line item. If the discount wasn't applied at the order level (all), then the discount name and amount are displayed.

{% if line.discount_allocations %}
    {% for discount_allocation in line.discount_allocations %}
        {% if discount_allocation.discount_application.target_selection != 'all' %}
            {{ discount_allocation.discount_application.title | upcase }}
            (-{{ discount_allocation.amount | money }})
        {% endif %}
    {% endfor %}
{% endif %}

The result might look like this:

SPRING5 (-$5.00)

Discount_allocation properties

Each discount_allocation in the list of discount_allocations has the following properties.

Description of discount_allocation properties
Property Description
discount_allocation.amount
The amount of money saved by the customer on a line item. Must be entered in a loop if you want to allow multiple discount codes.
discount_allocation.discount_application
The discount application that allocates the amount on the line item.

Discount_application properties

Each discount_application in the list of discount_applications has the following properties.

Description of discount_application properties
Property Description
discount_application.target_selection

Describes how a discount selects line items in the cart to be discounted. One of:

  • all: The discount applies to all line items.
  • entitled: The discount applies to a particular subset of line items, often defined by a condition.
  • explicit: The discount applies to a specifically selected line item or shipping line.
discount_application.target_type
The type of item that a discount applies to (line_item or shipping_line).
discount_application.title

The customer-facing name of the discount.

Examples: Welcome10 or CBBWQQAKYBYY

discount_application.total_allocated_amount
The total amount that the price of an order is reduced by the discount.
discount_application.type
The type of the discount. One of: automatic, discount_code, manual, or script.
discount_application.value
The value of the discount.
discount_application.value_type
The value type of the discount. One of: fixed_amount or percentage.

Email notification properties

Description of email notification properties
Property Description
shop.email_logo_url
The url for the logo specified in the Customize email templates section of the admin.
shop.email_logo_width
The logo width (pixels) specified in the Customize email templates section of the admin.
shop.email_accent_color
The HEX code for the accent color specified in the Customize email templates section of the admin.

准备好开始使用 Shopify 进行销售了吗?

免费试用