从 Order Printer 应用迁移到 Shopify Order Printer

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

这些变量可以用 fulfillmentsorder.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_gatewaystransactions.<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 仅将当前有效支付网关的一小部分映射到这些类别。支付网关提供商会管理客户使用的付款方式类型。

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

免费试用