Shopify Order Printer Liquid 变量和筛选条件参考

您可以使用 Liquid 并使用 Shopify Order Printer 应用来创建自己的自定义模板。使用 Liquid,您可以创建文本模板,并根据每个订单的唯一数据进行呈现。

此页面上列出的 Liquid 参考是 Liquid 开源版本的扩展,旨在用于 Shopify Order Printer 应用。若要根据 ordershop 属性来呈现信息,您可以使用此参考中的对象、标签和筛选条件列表来自定义模板。您还可以使用 Admin GraphQL 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 中可用的以下商店属性列表:

  • 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

订单项目

查看 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_price 值和 line_item.final_line_price 值分别等于 line_item.original_price 值和 line_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

税款项目

查看 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 筛选条件

用法

若要对输出应用筛选条件,在输出的花括号分隔符 {{ }} 中添加筛选条件和任何筛选参数,加上管道字符 | 前缀。在下面的示例中,产品是对象,标题是它的属性,大写是要应用的筛选条件:

{{ product.title | upcase }}

如果 product.titleHealth potion 值,HEALTH POTION 则为 upcase 筛选条件的输出。

请参阅 Shopify Themes Liquid 参考中的筛选条件部分,了解有关如何使用 Liquid 筛选条件的详细信息。

用于地址对象的筛选条件

  • format_address

有关使用示例,请参阅 Shopify Themes Liquid 文档了解 format_address

用于任何文本/字符串的筛选条件

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

有关使用示例,请参阅 Shopify Themes 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 Themes Liquid 文档了解资金筛选条件

用于将对象转换为 json 的筛选条件

  • json

有关使用示例,请参阅 Shopify Themes Liquid 文档了解 json 筛选条件

用于权重含义数字的筛选条件

  • weight
  • weight_with_unit

有关使用示例,请参阅 Shopify Themes Liquid 文档了解单位权重

用于标签的筛选条件

  • highlight_active_tag
  • link_to_add_tag
  • link_to_remove_tag
  • link_to_tag

有关使用示例,请参阅 Shopify Themes Liquid 文档了解标签筛选条件

用于 URL 的筛选条件

  • 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 Themes Liquid 文档了解媒体html 筛选条件。

用于集合的筛选条件

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

有关使用示例,请参阅 Shopify Themes Liquid 文档了解集合筛选条件

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

免费试用