匯入的 Order Printer 範本疑難排解
當您從舊版 Order Printer app 移轉您的範本至新的 Shopify Order Printer app 時,系統會更新您的 Liquid 變數,以確保與新 app 相容。少數情況下,您可能需要對匯入的範本進行疑難排解。
如果您匯入的範本未正確列印,可能需要在新的 Shopify Order Printer app 中手動編輯範本程式碼。請檢視以下範本可能無法正確匯入的最常見原因:
- 範本包含自訂 CSS
- 範本包含中繼欄位
- Liquid 變數可能未正確更新
本頁提供將自訂範本匯入新的 Shopify Order Printer app 時,如何疑難排解潛在問題的詳細說明。
更新常見 CSS 設計自訂項目
如果您要移轉的範本包含自訂 CSS,可能需要手動更新範本中的 CSS 程式碼,才能正確顯示各種設計元素,例如圖片、自訂字型、標誌或條碼。
更新中繼欄位變數
若要存取中繼欄位,您必須指定該中繼欄位的命名空間,且不需要在變數後加上 .value。深入瞭解中繼欄位定義。
例如,請改用 product.metafields.custom.manufacturerid 變數,而不是 product.metafields.custom.manufacturerid.value 變數。
若要確認每個中繼欄位的命名空間值,請參考您 Shopify 管理介面中的 自訂資料 頁面。中繼欄位定義會依其所參照的物件分組,例如商品、子類或訂單。
更新常見 Liquid 變數
多數情況下,您使用的 Liquid 變數會在移轉過程中自動更新。不過,如果範本未正確移轉,且您使用本節列出的變數,則可能需要手動以新變數取代舊變數。Shopify Order Printer app 與舊版 Order Printer app 使用的變數有所不同。
例如,若您使用 date 變數,則需改用 created_at 變數。
訂單變數
訂單變數在 Shopify Order Printer app 中的使用方式不同。若要存取訂單變數,您需要加上 order. 前綴。例如,要存取 billing_address 變數,需使用 order.billing_address。
以下常見的訂單變數,無需加上 order. 前綴即可存取:
line_itemstax_linesfulfillmentstransactionsrefundsshipping_methodscustomer
例如,若要存取商品項目變數,您可以使用 line_items 或 order.line_items。
您也可以在範本中自行建立別名變數。例如,您可以使用 {% assign fulfillments_count = order.fulfillments | size %} 的 Liquid 語法,接著在程式碼中以 {{ fulfillments_count }} 來引用。
| 舊版 Order Printer app 中的變數 | 新版 Shopify Order Printer app 中的變數 |
|---|---|
line_items |
|
credit_card | 請使用 transactions.<each>.payment_details 變數,依訂單中的每筆交易取得付款詳情。 |
current_shipping_price | shipping_price |
date | 請改用 created_at 變數。使用 date 過濾器來格式化時間戳記,例如:{{ order.created_at | date: "%B %e, %Y" }}。 |
gateways | unique_gateways 或 transactions.<each>.gateway |
order_currency | currency |
processed_at | 使用 created_at 變數。此變數的值等同於來自 GraphQL API 的 order.processed_at,代表訂單實際處理的時間,而非訂單匯入 Shopify 的時間。它與舊版 Order Printer app 的 order.processed_at 相同。您可以使用 date 篩選器來格式化時間戳記,例如:{{ order.created_at | date: "%B %e, %Y" }}。 |
payment_transactions |
在 Liquid 語法中,透過 where 針對
|
refund_transactions | 在 Liquid 語法中,使用 where 透過 order.transactions 篩選 kind 狀態,或是透過迴圈以及內部的 if 進行篩選,如下列範例所示:{% assign refund_transactions = order.transactions | where: "kind", "refund" %} |
shipping_line | shipping_methods | first |
shipping_lines | shipping_methods |
show_line_item_taxes | tax_lines.size > 0。您可以在範本開頭將其定義為變數並多次參照此變數,如下列範例所示:{% if tax_lines.size > 0 %}
{% assign show_line_item_taxes = true %}
{% else %}
{% assign show_line_item_taxes = false %}
{% endif %} |
total_tax | tax_price |
total_paid | net_payment |
LineItem 變數
| 舊版 Order Printer app 中的變數 | 新版 Shopify Order Printer app 中的變數 |
|---|---|
fulfillable_quantity | quantity - successfully_fulfilled_quantity |
fulfilled | quantity == successfully_fulfilled_quantity |
name | title |
product_title | product.title |
unit_discount | quantity ? line_level_total_discount / quantity : 0 |
variant_title | variant.title |
weight | grams |
出貨作業變數
| 舊版 Order Printer app 中的變數 | 新版 Shopify Order Printer app 中的變數 |
|---|---|
date | created_at |
商店變數
| 舊版 Order Printer app 中的變數 | 新版 Shopify Order Printer app 中的變數 |
|---|---|
owner | account_owner.name |
address | shop.address.address1 |
address2 | shop.address.address2 |
city | shop.address.city |
country | shop.address.country |
country_code | shop.address.country_code |
province | shop.address.province |
province_code | shop.address.province_code |
zip | shop.address.zip |
地址變數
| 舊版 Order Printer app 中的變數 | 新版 Shopify Order Printer app 中的變數 |
|---|---|
latitude | 如果 address 變數參照自 location 屬性,則 location 物件本身即會提供緯度和經度。 |
longitude | 如果 address 變數參照自 location 屬性,則 location 物件本身即會提供緯度和經度。 |
退款變數
| 舊版 Order Printer app 中的變數 | 新版 Shopify Order Printer app 中的變數 |
|---|---|
date | 請改用 created_at 變數。使用 date 過濾器來格式化時間戳記,例如:{{ order.created_at | date: "%B %e, %Y" }}。 |
ShippingLine 變數
| 舊版 Order Printer app 中的變數 | 新版 Shopify Order Printer app 中的變數 |
|---|---|
current_price | price |
price | original_price |
交易變數
以下交易變數已移除,且無法在 Shopify Order Printer app 中替代:
authorizationmessagetest
子類變數
| 舊版 Order Printer app 中的變數 | 新版 Shopify Order Printer app 中的變數 |
|---|---|
grams | weight |
中繼欄位變數
若要存取中繼欄位,您需要指定該中繼欄位的命名空間,且不需要在變數後加上 .value。
瞭解詳情:metafield definitions。
例如,請不要使用 product.metafields.manufacturerid.value 變數,改用 product.metafields.custom.manufacturerid 變數。
若要找出每個中繼欄位的命名空間值,請參考 Shopify 管理介面中的 Custom data 頁面。中繼欄位定義會依其參照的物件分組,例如商品、子類或訂單。
過濾器對應
| 舊版 Order Printer app 的過濾器名稱 | 新版 Shopify Order Printer app 的過濾器名稱 |
|---|---|
files_url | file_url |
payment_method 與 payment_methods | 請在訂單交易上使用 transaction.gateway_display_name 欄位。付款方式不再劃分為特定類型,例如 {credit card, debit card, bank transfer}。舊版 Order Printer app 僅將目前可用的少數付款閘道對應到這些類別。付款閘道提供者會在其系統中管理顧客所使用的付款方式類型。 |