从 Order Printer 应用迁移到 Shopify Order Printer
已于 May 20, 2024 打印了此页面。若要查看当前版本,请访问 https://help.shopify.com/zh-CN/manual/orders/printing-orders/shopify-order-printer/migration。
Shopify Order Printer 中的 Liquid 实现与原来的 Order Printer 略有不同。若要迁移模板,您需要手动复制现有模板中的代码,将它们粘贴到新应用中,然后根据本指南概述进行必要的调整。添加到模板的任何自定义 CSS 也需要转移到新应用中并进行调整。
本页相关主题
从全局命名空间中删除订单属性
若要访问订单属性,在它们前面加上 order.
。例如, billing_address
现在以 order.billing_address
访问。
为了方便,一些常用的订单属性仍然可在没有 order.
前缀的情况下访问:
-
line_items
-
tax_lines
-
fulfillments
-
transactions
-
discounts
-
refunds
-
shipping_methods
-
customer
这些变量可以用 fulfillments
或 order.fulfillments
等访问。
字段弃用
根据最新 Shopify 数据模型,某些对象上的多个字段已被重命名或弃用,并使用以下段落中提供的替换或替代方法。如果您的模板访问任意这些字段,请用提供的替换字段或代码碎片替换。
订购
实现差异:
-
line_items
。已退款订单项目不包含在 line_items 集合中。请通过refunds.<each>.refunded_line_items
访问已退款订单项目。
弃用字段的替换项如下:
-
credit_card
。使用基于订单每笔交易的付款详细信息:transactions.each.payment_details
。 -
current_shipping_price
。请改为使用shipping_price
。 -
date
。请改为使用created_at
。 -
gateways
。请改为使用unique_gateways
或transactions.<each>.gateway
。 -
order_currency
。请改为使用currency
。 -
processed_at
。请改为使用created_at
。 -
payment_transactions
。使用 where 或循环和if
等 Liquid 语法在order.transactions
中筛选类型和状态。 -
refund_transactions
。使用 where 或循环和if
等 Liquid 语法在order.transactions
中筛选类型和状态。 -
shipping_line
。使用shipping_methods | first
。 -
shipping_lines
。使用shipping_methods
。 -
show_line_item_taxes
。使用tax_lines.size > 0
。您可以在模板开头将它定义为一个变量,并多次引用:{% assign show_line_item_taxes = tax_lines.size > 0 %}
。 -
total_tax
。使用tax_price
。 -
total_paid
。使用net_payment
。
订单项目
弃用字段的替换项如下:
-
fulfillable_quantity
。使用quantity - successfully_fulfilled_quantity
。 -
fulfilled
。计算quantity == successfully_fulfilled_quantity
条件。 -
name
。使用title
。 -
product_title
。使用product.title
。 -
unit_discount
。计算quantity ? total_iscount / quantity : 0
。 -
variant_title
。使用variant.title
。 -
weight
。使用grams
。
发货
弃用字段的替换项如下:
-
date
。使用created_at
。
Shop
弃用字段的替换项如下:
-
owner
- 使用account_owner.name
。
对于以下字段,请引用为 shop.address.<field_name>
:
-
address
- 使用shop.address.address1
。 -
address2
- 使用shop.address.address2
。 -
city
- 使用shop.address.city
。 -
country
- 使用shop.address.city
。 -
country_code
- 使用shop.address.country_code
。 -
province
- 使用shop.address.province
。 -
province_code
- 使用shop.address.province_code
。 -
zip
- 使用shop.address.zip
。
地址
弃用字段的替换项如下:
-
latitude
- 如果address
是从location
引用的,location
对象本身中会提供纬度和经度。 -
Longitude
- 如果address
是从location
引用的,location
对象本身中会提供纬度和经度。
退款
弃用字段的替换项如下:
-
date
。使用created_at
。
发货项目
弃用字段的替换项如下:
-
current_price
。使用price
。 -
price
。使用original_price
。
交易
已删除字段:
-
authorization
-
message
-
test
多属性
弃用字段的替换项如下:
-
grams
。使用weight
。
筛选条件弃用
弃用字段的替换项如下:
-
files_url
。使用file_url
。 -
payment_method
,payment_methods
。在订单交易上使用 transaction.gateway_display_name 字段。付款方式不再分类为特定类型,例如{credit card, debit card, bank transfer}
。旧版 Order Printer 仅将当前有效支付网关的一小部分映射到这些类别。支付网关提供商会管理客户使用的付款方式类型。