Shopify Order Printer 的 Liquid 變數和篩選條件參考資料。

您可以使用 Shopify Order Printer 應用程式和 Liquid 自行建立自訂範本。Liquid 可以按照每筆訂單的不同資料建立和轉譯文字範本。

此頁面上列出的 Liquid 參考資料是 Liquid 開放原始碼版本的延伸,主要用於 Shopify Order Printer 應用程式。若要根據 ordershop 屬性轉譯資訊,您可以使用此參考資料中的物件、標籤和篩選條件清單來自訂範本。您也可以參閱 GraphQL Admin API 文件,進一步瞭解物件欄位的詳細資訊。

使用變數和屬性

在 Shopify Order Printer 範本中,核心資料物件為 ordershop。您可以使用 order.variable_name 存取訂單屬性。

下列常用訂單屬性無需 order. 前綴即可存取:

  • line_items
  • tax_lines
  • fulfillments
  • transactions
  • discounts
  • refunds
  • shipping_methods
  • customer

例如,若要存取商品項目變數,可以使用 line_itemsorder.line_items

Shopify Order Printer 提供的 Liquid 變數

您可以使用以下類別:這裡的屬性以英文字母順序排列。

訂單

Shopify Order Printer 可以使用以下訂單屬性:

  • attributes
  • b2b
  • billing_address
  • cancel_reason
  • cancel_reason_label
  • cancelled
  • cancelled_at
  • cart_level_discount_applications
  • checkout_id
  • checkout_payment_collection_url
  • company
  • company_location
  • confirmation_number
  • created_at。系統處理訂單的時間,等同於來自 GraphQL API 的 order.processed_at。使用 date 篩選條件設定時間戳記的格式,例如使用 {{ order.created_at | date: "%B %e, %Y" }}
  • customer
  • discounts。已停用,因為並未擷取所有折扣類型和詳細資訊。order.discounts 屬性已更換為 order.discount_applications
  • discounts_amount。已停用,因為並未擷取所有折扣類型和詳細資訊。order.discounts 屬性已更換為 order.total_discounts
  • discount_applications
  • discounts_savings。已停用,因為並未擷取所有折扣類型和詳細資訊。order.discounts 屬性已更換為 -
  • email
  • fees
  • financial_status
  • financial_status_label
  • fulfilled_line_items
  • fulfillment_aborted
  • fulfillment_status
  • fulfillments
  • gateway
  • id
  • item_count
  • landing_site
  • landing_site_ref
  • line_items
  • line_items_subtotal_price
  • location
  • metafields
  • name
  • net_payment
  • note
  • order_name
  • order_number
  • order_status_url
  • payment
  • payment_details
  • po_number
  • refunds
  • requires_shipping
  • shipping_address
  • shipping_method
  • shipping_methods
  • shipping_price
  • shop
  • shop_name
  • subtotal_price
  • tags
  • tax_lines
  • tax_price
  • tip_line_items
  • total_discounts
  • total_duties
  • total_landed_cost_additional_fees
  • total_net_amount
  • total_outstanding
  • total_price
  • total_refunded_amount
  • total_tip
  • transactions
  • unacceptable_risks
  • unfulfilled_line_items
  • unique_gateways
  • user
  • void_transactions

Shop

請看以下 Shopify Order Printer 提供的 Shop 屬性:

  • accepts_gift_cards
  • account_owner
  • allows_discounts
  • checkout
  • checkout_requires_confirmation_step
  • collections_count
  • contact_information
  • currency
  • customer_accounts_enabled
  • customer_accounts_optional
  • description
  • domain
  • email
  • email_accent_color
  • email_logo_url
  • email_logo_width
  • email_marketing
  • enabled_currencies
  • enabled_locales
  • enabled_payment_types
  • features
  • id
  • latitude
  • legal_notice
  • longitude
  • metafields
  • money_format
  • money_with_currency_format
  • name
  • password_message
  • permanent_domain
  • phone
  • policies
  • privacy_policy
  • products_count
  • refund_policy
  • secure_url
  • shipping_policy
  • subscription_policy
  • terms_of_sale
  • terms_of_service
  • types
  • url

LineItem

請看以下 Shopify Order Printer 提供的商品項目屬性:

  • aggregated_update
  • applied_discounts。已停用,因為並非所有折扣類型和詳細資訊都可供使用。line_item.discounts 屬性已更換為 line_item.discount_allocations
  • current_quantity
  • discount_allocations
  • discounts。已停用,因為並非所有折扣類型和詳細資訊都可供使用。line_item.discounts 屬性已更換為 line_item.discount_allocations
  • final_line_price
  • final_price
  • fulfillment
  • fulfillment_service
  • gift_card
  • grams
  • groups
  • id
  • image
  • index
  • item_updates
  • json_filter
  • key
  • line_level_discount_allocations
  • line_level_total_discount
  • line_price。已停用,因為不包括自動折扣和折扣代碼的折扣。line_item.line_price 屬性已更換為 line_item.final_line_price
  • message
  • options_with_values
  • original_line_price
  • original_price
  • price。已停用,因為不包括自動折扣和折扣代碼的折扣。line_item.price 屬性已更換為 line_item.final_price
  • product
  • product_id
  • properties
  • quantity
  • refunded_quantity
  • requires_shipping
  • selling_plan_allocation
  • sku
  • successfully_fulfilled_quantity
  • tax_lines
  • taxable
  • title
  • total_discount。已停用,因為不包括自動折扣和折扣代碼的折扣。line_item.total_discount 屬性已更換為 line_item.line_level_total_discount
  • unit_price
  • unit_price_measurement
  • url
  • url_to_remove
  • variant
  • variant_id
  • vendor

出貨作業

請看以下 Shopify Order Printer 提供的出貨作業屬性:

  • created_at。使用 date 篩選條件設定時間戳記的格式,例如使用 {{ fulfillment.created_at | date: "%B %e, %Y" }}
  • estimated_delivery_at
  • fulfillment_line_items
  • item_count
  • line_items
  • requires_shipping
  • tracking_company
  • tracking_number
  • tracking_numbers
  • tracking_url
  • tracking_urls
  • updated_at

地址

請看以下 Shopify Order Printer 提供的地址屬性:

  • address1
  • address2
  • city
  • company
  • country
  • country_code
  • country_upper
  • errors
  • first_name
  • id
  • last_name
  • name
  • phone
  • province
  • province_code
  • street
  • summary
  • translated_country_name
  • translated_province_name
  • url
  • zip

客戶

請看以下 Shopify Order Printer 提供的顧客屬性:

  • accepts_marketing
  • account_activation_url
  • addresses
  • addresses_count
  • b2b?
  • default_address
  • email
  • first_name
  • has_account
  • id
  • last_name
  • last_order
  • metafields
  • name
  • new_address
  • orders
  • orders_count
  • payment_methods
  • phone
  • reset_password_url
  • subscribe_url
  • tags
  • tax_exempt
  • total_spent

DiscountApplication

請查看以下 Shopify Order Printer 提供的 DiscountApplication 屬性清單:

  • target_selection
  • target_type
  • title
  • total_allocated_amount
  • type
  • value_type
  • value

列印折扣

您可以將折扣套用到整筆訂單,或只套用到特定的商品項目:

  • 訂單層級折扣:套用於整筆訂單。您可以在列印訂單發票時,將這些折扣另外顯示在底部。
  • 商品項目層級折扣:套用於個別品項。您可以在列印個別品項商品細節時,在商品項目區段列出這些折扣。

您可以用以下變數存取折扣資訊:

  • 使用 order.total_discounts 值和 order.discount_applications 集合存取所有套用於訂單或其中任何商品項目的折扣。
  • 使用 line_item.line_level_total_discount 值或 line_item.line_level_discount_allocations 集合存取商品項目折扣。

    • 使用 line_item.original_price 值存取商品項目套用折扣前的原價。
    • 使用 line_item.final_price 值存取商品項目套用所有相關商品項目層級折扣之後的價格。
    • line_item.original_line_priceline_item.final_line_price 兩種值,等於 line_item.original_priceline_item.final_price 乘以 line_item.quantity 的結果。
  • 使用 order.cart_level_discount_applications 集合存取訂單層級折扣。

列印商品項目層級折扣的範例程式碼區塊:

{% for line_item in order.line_items %}
  <tr>
    <td>{{ line_item.quantity }}</td>
    <td>{{ line_item.title }}
    {% if line_item.line_level_discount_allocations.size > 0 %}
      <span class="subduedText">
        {% for discount_allocation in line_item.line_level_discount_allocations %}
        <br>{{ discount_allocation.discount_application.title }} (-{{ discount_allocation.amount | money }})
        {% endfor %}
      </span>
    {% endif %}
    </td>
    <td style="text-align: right;">
      {% if line_item.original_price != line_item.final_price %}
        <span class="subduedText"><s>{{ line_item.original_price | money }}</s></span>
      {% endif %}
      {{ line_item.final_price | money }}
    </td>
  </tr>
{% endfor %}

列印訂單層級折扣的範例程式碼區塊:

{% for discount_application in order.cart_level_discount_applications %}
<tr>
  <td colspan="2" style="text-align: right;">{% if discount_application.title %}<span class="subduedText">{{ discount_application.title }}</span>{% endif %}</td>
  <td style="text-align: right;">-{{ discount_application.total_allocated_amount | money }}</td>
</tr>
{% endfor %}

DiscountAllocation

請查看以下 Shopify Order Printer 提供的 DiscountAllocation 屬性清單:

  • amount
  • discount_application

折扣

請看以下 Shopify Order Printer 提供的折扣屬性:

  • amount
  • code
  • free_shipping_discount
  • id
  • savings
  • title
  • total_amount
  • total_savings

產品

請看以下 Shopify Order Printer 提供的商品屬性:

  • as_json
  • available
  • collections
  • compare_at_price
  • compare_at_price_max
  • compare_at_price_min
  • compare_at_price_varies
  • content
  • created_at
  • description
  • featured_image
  • featured_media
  • first_available_variant
  • gift_card?
  • handle
  • has_only_default_variant
  • id
  • images
  • json_filter
  • media
  • metafields
  • object_type
  • options
  • options_by_name
  • options_with_values
  • price
  • price_max
  • price_min
  • price_varies
  • published_at
  • requires_selling_plan
  • selected_or_first_available_selling_plan_allocation
  • selected_or_first_available_variant
  • selected_selling_plan
  • selected_selling_plan_allocation
  • selected_variant
  • selling_plan_groups
  • tags
  • template_suffix
  • title
  • type
  • url
  • variants
  • vendor

變體

請看以下 Shopify Order Printer 提供的子類屬性:

  • as_json
  • available
  • barcode
  • compare_at_price
  • featured_image
  • featured_media
  • id
  • image
  • incoming
  • inventory_management
  • inventory_policy
  • inventory_quantity
  • json_filter
  • metafields
  • next_incoming_date
  • option1
  • option2
  • option3
  • options
  • price
  • product
  • requires_selling_plan
  • requires_shipping
  • selected_selling_plan_allocation
  • selling_plan_allocations
  • sku
  • store_availabilities
  • taxable
  • title
  • unit_price
  • unit_price_measurement
  • url
  • weight
  • weight_in_unit
  • weight_unit

退款

請看以下 Shopify Order Printer 提供的退款屬性:

  • amount
  • created_at
  • id
  • note
  • refund_line_items
  • restock
  • transactions

運送路線

請看以下 Shopify Order Printer 提供的運送路線屬性:

  • handle
  • id
  • original_price
  • tax_lines
  • title

TaxLine

請看以下 Shopify Order Printer 提供的稅項屬性:

  • price
  • rate
  • rate_percentage
  • title

交易

請看以下 Shopify Order Printer 提供的交易項目屬性:

  • amount
  • buyer_pending_payment_instructions
  • buyer_pending_payment_notice
  • created_at
  • gateway
  • gateway_display_name
  • id
  • kind
  • name
  • payment_details
  • receipt
  • show_buyer_pending_payment_instructions
  • status
  • status_label

中繼欄位

父系物件中附有一個中繼欄位。如果想瞭解如何存取特定物件的中繼欄位,請參閱存取中繼欄位

中繼欄位支援多種資料類型,這些類型決定了中繼欄位內儲存的資訊類型。如果想存取中繼欄位,中繼欄位的存取路徑可分成兩層架構:

  • 命名空間 - 為了避免衝突而分成一組的中繼欄位。
  • 金鑰 - 中繼欄位的名稱

因此,您可以藉由以下語法存取中繼欄位的物件:{{ resource.metafields.namespace.key }}

命名:<object>.metafields.<namespace>.<key>。例如 order.metafields.shipping.express_delivery_status

類型:

  • String
  • Array - 使用 [] 建立索引。範例: order.metafield.shipping.express_delivery_status[0]
  • Integer
  • Boolean
  • Date

備註:不支援 Metaobject 類型。

支援中繼欄位的物件:

  • Order
  • Customer
  • Product
  • Variant
  • Location

Shopify Order Printer 提供的 Liquid 篩選條件

使用

如果想對輸出內容套用篩選條件,請在輸出內容的大括號分隔符號 {{ }} 當中加入篩選條件和任何篩選條件參數,並在前方加上直線字元 |。在以下範例中,商品是物件、標題是屬性,而 upcase 是套用的篩選條件:

{{ product.title | upcase }}

如果 product.title 的值是 Health potion,則從 upcase 篩選條件輸出的內容將會是 HEALTH POTION

請參閱 Shopify 佈景主題 Liquid 參考資料的篩選條件區段,以便詳細瞭解如何使用 Liquid 篩選條件。

套用在地址物件的篩選條件

  • format_address

使用範例請參閱 Shopify 佈景主題 Liquid 文件的 format_address

套用在任何文字 / 字串上的篩選條件

  • camelcase
  • camelize
  • encode_url_component
  • format_code
  • handle
  • highlight
  • pad_spaces
  • paragraphize
  • pluralize
  • url_escape
  • url_param_escape

使用範例請參閱 Shopify 佈景主題 Liquid 文件的字串篩選條件

套用在金錢相關數字上的篩選條件

  • money
  • money_with_currency
  • money_without_currency
  • money_without_trailing_zeros

Shopify Order Printer 在設定貨幣格式時,會使用 Shopify 管理介面中所設定的電子郵件通知幣別格式選項。您可以變更幣別格式。在 Shopify 管理介面設定 Email with currencyEmail without currency 值,以變更 Shopify Order Printer 中的貨幣篩選條件格式。

使用範例請參閱 Shopify 佈景主題 Liquid 文件的金錢篩選條件

套用至將物件轉換為 json 的篩選條件

  • json

使用範例請參閱 Shopify 佈景主題 Liquid 文件的 json 篩選條件

套用在重量相關數字上的篩選條件

  • weight
  • weight_with_unit

使用範例請參閱 Shopify 佈景主題 Liquid 文件的附單位重量

套用在標籤上的篩選條件

  • highlight_active_tag
  • link_to_add_tag
  • link_to_remove_tag
  • link_to_tag

使用範例請參閱 Shopify 佈景主題 Liquid 文件的標籤篩選條件

套用在網址上的篩選條件

  • article_img_url
  • asset_img_url
  • asset_url
  • cdn_asset_url
  • collection_img_url
  • file_img_url
  • file_url
  • global_asset_url
  • image_url
  • img_tag
  • img_url
  • link_to
  • payment_icon_png_url
  • payment_type_img_url
  • payment_type_svg_tag
  • placeholder_svg_tag
  • product_img_url
  • script_tag
  • shopify_asset_url
  • stylesheet_tag

使用範例請參閱 Shopify 佈景主題 Liquid 文件的多媒體檔案HTML 篩選條件。

套用在商品系列上的篩選條件

  • link_to_type
  • link_to_vendor
  • sort_by
  • url_for_type
  • url_for_vendor
  • within

使用範例請參閱 Shopify 佈景主題 Liquid 文件的商品系列篩選條件

準備好開始透過 Shopify 銷售商品了嗎?

免費試用