Tham chiếu về biến và bộ lọc Liquid cho Shopify Order Printer
Bạn có thể sử dụng Liquid để xây dựng các mẫu tùy chỉnh của riêng mình bằng ứng dụng Shopify Order Printer. Với Liquid, bạn có thể tạo các mẫu văn bản và kết xuất chúng dựa trên dữ liệu duy nhất của mỗi đơn hàng.
Các tham chiếu Liquid liệt kê trên trang này là tiện ích mở rộng của phiên bản Liquid nguồn mở và được dùng trên ứng dụng Shopify Order Printer. Để kết xuất thông tin dựa trên các thuộc tính order và shop, bạn có thể sử dụng danh sách các đối tượng, thẻ và bộ lọc từ tham chiếu này để tùy chỉnh mẫu của mình. Bạn cũng có thể dùng tài liệu Admin GraphQL API để tìm hiểu thông tin chi tiết về các trường đối tượng.
Trên trang này
Sử dụng biến và thuộc tính
Trong các mẫu Shopify Order Printer, đối tượng dữ liệu cốt lõi là order và shop. Bạn có thể sử dụng order.variable_name để truy cập các thuộc tính của đơn hàng.
Các thuộc tính đơn hàng thường dùng sau đây có thể được truy cập mà không cần tiền tố order.:
line_itemstax_linesfulfillmentstransactionsdiscountsrefundsshipping_methodscustomer
Ví dụ: nếu muốn truy cập biến mục hàng, bạn có thể sử dụng line_items hoặc order.line_items.
Các biến Liquid có sẵn trong Shopify Order Printer
Có các lớp sau đây. Các thuộc tính được liệt kê theo thứ tự bảng chữ cái.
Đơn hàng
Các thuộc tính Đơn hàng sau đây có sẵn trong Shopify Order Printer:
attributesb2bbilling_addresscancel_reasoncancel_reason_labelcancelledcancelled_atcart_level_discount_applicationscheckout_idcheckout_payment_collection_urlcompanycompany_locationconfirmation_numbercreated_at. Thời điểm xử lý đơn hàng. Thời gian này bằng vớiorder.processed_attừ API GraphQL. Sử dụng bộ lọcdateđể định dạng dấu thời gian, ví dụ bằng{{ order.created_at | date: "%B %e, %Y" }}.customerdiscounts. Không dùng nữa vì không ghi lại mọi loại và chi tiết khoản chiết khấu. Thuộc tínhorder.discountsđã được thay thế bằngorder.discount_applications.discounts_amount. Không dùng nữa vì không ghi lại mọi loại và chi tiết khoản chiết khấu. Thuộc tínhorder.discountsđã được thay thế bằngorder.total_discounts.discount_applicationsdiscounts_savings. Không dùng nữa vì không ghi lại mọi loại và chi tiết khoản chiết khấu. Thuộc tínhorder.discountsđã được thay thế bằng-.emailfeesfinancial_statusfinancial_status_labelfulfilled_line_itemsfulfillment_abortedfulfillment_statusfulfillmentsgatewayiditem_countlanding_sitelanding_site_refline_itemsline_items_subtotal_pricelocationmetafieldsnamenet_paymentnoteorder_nameorder_numberorder_status_urlpaymentpayment_detailspo_numberrefundsrequires_shippingshipping_addressshipping_methodshipping_methodsshipping_priceshopshop_namesubtotal_pricetagstax_linestax_pricetip_line_itemstotal_discountstotal_dutiestotal_landed_cost_additional_feestotal_net_amounttotal_outstandingtotal_pricetotal_refunded_amounttotal_tiptransactionsunacceptable_risksunfulfilled_line_itemsunique_gatewaysuservoid_transactions
Cửa hàng
Xem lại danh sách thuộc tính Cửa hàng sau có sẵn trong Shopify Order Printer:
accepts_gift_cardsaccount_ownerallows_discountscheckoutcheckout_requires_confirmation_stepcollections_countcontact_informationcurrencycustomer_accounts_enabledcustomer_accounts_optionaldescriptiondomainemailemail_accent_coloremail_logo_urlemail_logo_widthemail_marketingenabled_currenciesenabled_localesenabled_payment_typesfeaturesidlatitudelegal_noticelongitudemetafieldsmoney_formatmoney_with_currency_formatnamepassword_messagepermanent_domainphonepoliciesprivacy_policyproducts_countrefund_policysecure_urlshipping_policysubscription_policyterms_of_saleterms_of_servicetypesurl
LineItem
Xem lại danh sách sau về các thuộc tính Mục hàng có sẵn trong Shopify Order Printer:
aggregated_updateapplied_discounts. Đã ngừng sử dụng vì không có sẵn tất cả các loại và chi tiết giảm giá. Thuộc tínhline_item.discountsđã được thay thế bằngline_item.discount_allocations.current_quantitydiscount_allocationsdiscounts. Đã ngừng sử dụng vì không có sẵn tất cả các loại và chi tiết giảm giá. Thuộc tínhline_item.discountsđã được thay thế bằngline_item.discount_allocations.final_line_pricefinal_pricefulfillmentfulfillment_servicegift_cardgramsgroupsidimageindexitem_updatesjson_filterkeyline_level_discount_allocationsline_level_total_discountline_price. Đã ngừng sử dụng vì không bao gồm khoản giảm giá từ giảm giá tự động và mã giảm giá. Thuộc tínhline_item.line_priceđã được thay thế bằngline_item.final_line_price.messageoptions_with_valuesoriginal_line_priceoriginal_priceprice. Đã ngừng sử dụng vì không bao gồm khoản giảm giá từ giảm giá tự động và mã giảm giá. Thuộc tínhline_item.priceđã được thay thế bằngline_item.final_price.productproduct_idpropertiesquantityrefunded_quantityrequires_shippingselling_plan_allocationskusuccessfully_fulfilled_quantitytax_linestaxabletitletotal_discount. Đã ngừng sử dụng vì không bao gồm khoản giảm giá từ giảm giá tự động và mã giảm giá. Thuộc tínhline_item.total_discountđã được thay thế bằngline_item.line_level_total_discount.unit_priceunit_price_measurementurlurl_to_removevariantvariant_idvendor
Hoàn tất đơn hàng
Xem lại danh sách sau về các thuộc tính Hoàn tất đơn hàng có sẵn trong Shopify Order Printer:
created_at. Sử dụng bộ lọcdateđể định dạng dấu thời gian, ví dụ như{{ fulfillment.created_at | date: "%B %e, %Y" }}.estimated_delivery_atfulfillment_line_itemsitem_countline_itemsrequires_shippingtracking_companytracking_numbertracking_numberstracking_urltracking_urlsupdated_at
Địa chỉ
Xem danh sách sau về các thuộc tính Địa chỉ dùng được trong Shopify Order Printer:
address1address2citycompanycountrycountry_codecountry_uppererrorsfirst_nameidlast_namenamephoneprovinceprovince_codestreetsummarytranslated_country_nametranslated_province_nameurlzip
Khách hàng
Xem danh sách sau về các thuộc tính Khách hàng dùng được trong Shopify Order Printer:
accepts_marketingaccount_activation_urladdressesaddresses_countb2b?default_addressemailfirst_namehas_accountidlast_namelast_ordermetafieldsnamenew_addressordersorders_countpayment_methodsphonereset_password_urlsubscribe_urltagstax_exempttotal_spent
DiscountApplication
Xem danh sách sau về các thuộc tính DiscountApplication dùng được trong Shopify Order Printer:
target_selectiontarget_typetitletotal_allocated_amounttypevalue_typevalue
In chiết khấu
Có thể áp dụng chiết khấu cho toàn bộ đơn hàng hoặc cho các mục hàng cụ thể:
- Chiết khấu cấp đơn hàng: Áp dụng cho toàn bộ đơn hàng. Bạn có thể hiển thị riêng các khoản chiết khấu này ở dưới cùng khi in hóa đơn của đơn hàng.
- Chiết khấu cấp mục hàng: Áp dụng cho từng mặt hàng riêng lẻ. Bạn có thể đề cập đến các khoản chiết khấu này khi in chi tiết mặt hàng riêng lẻ trong phần mục hàng.
Bạn có thể truy cập thông tin chiết khấu bằng các biến sau:
- Truy cập tất cả các khoản chiết khấu đã áp dụng cho đơn hàng hoặc bất kỳ mục hàng nào của đơn hàng đó bằng giá trị
order.total_discountsvà bộ sưu tậporder.discount_applications. - Truy cập khoản chiết khấu cho mục hàng bằng giá trị
line_item.line_level_total_discounthoặc bộ sưu tậpline_item.line_level_discount_allocations. - Truy cập giá của mục hàng trước khi áp dụng bất kỳ khoản chiết khấu nào bằng giá trị
line_item.original_price. - Truy cập giá cuối cùng của mục hàng sau khi áp dụng tất cả các khoản chiết khấu cấp mục hàng có liên quan bằng giá trị
line_item.final_price. - Giá trị
line_item.original_line_pricevàline_item.final_line_pricebằng giá trịline_item.original_pricevàline_item.final_pricenhân vớiline_item.quantity. - Truy cập chiết khấu cấp đơn hàng bằng bộ sưu tập
order.cart_level_discount_applications.
Khối mã mẫu để in chiết khấu cấp mục hàng:
{% 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 %}Khối mã mẫu để in chiết khấu cấp đơn hàng:
{% 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 %}- Tìm hiểu thêm về các loại chiết khấu và cách làm việc với chiết khấu trong Liquid.
DiscountAllocation
Xem danh sách sau về các thuộc tính DiscountAllocation dùng được trong Shopify Order Printer:
amountdiscount_application
Discount
Xem danh sách sau về các thuộc tính Discount dùng được trong Shopify Order Printer:
amountcodefree_shipping_discountidsavingstitletotal_amounttotal_savings
Sản phẩm
Xem lại danh sách thuộc tính Sản phẩm sau đây có trong Shopify Order Printer:
as_jsonavailablecollectionscompare_at_pricecompare_at_price_maxcompare_at_price_mincompare_at_price_variescontentcreated_atdescriptionfeatured_imagefeatured_mediafirst_available_variantgift_card?handlehas_only_default_variantidimagesjson_filtermediametafieldsobject_typeoptionsoptions_by_nameoptions_with_valuespriceprice_maxprice_minprice_variespublished_atrequires_selling_planselected_or_first_available_selling_plan_allocationselected_or_first_available_variantselected_selling_planselected_selling_plan_allocationselected_variantselling_plan_groupstagstemplate_suffixtitletypeurlvariantsvendor
Mẫu mã
Xem lại danh sách thuộc tính Mẫu mã sau đây có trong Shopify Order Printer:
as_jsonavailablebarcodecompare_at_pricefeatured_imagefeatured_mediaidimageincominginventory_managementinventory_policyinventory_quantityjson_filtermetafieldsnext_incoming_dateoption1option2option3optionspriceproductrequires_selling_planrequires_shippingselected_selling_plan_allocationselling_plan_allocationsskustore_availabilitiestaxabletitleunit_priceunit_price_measurementurlweightweight_in_unitweight_unit
Hoàn tiền
Xem lại danh sách thuộc tính Hoàn tiền sau đây có trong Shopify Order Printer:
amountcreated_atidnoterefund_line_itemsrestocktransactions
ShippingLine
Xem lại danh sách thuộc tính Shipping Line sau đây có trong Shopify Order Printer:
handleidoriginal_priceprice. Đã ngừng hỗ trợ vì giá không bao gồm các khoản giảm giá cấp đơn hàng. Thuộc tínhshipping_line.priceđã được thay thế bằngshipping_line.price_with_discounts.price_with_discountstax_linestitle
TaxLine
Xem lại danh sách thuộc tính Tax Line sau đây có trong Shopify Order Printer:
priceraterate_percentagetitle
Giao dịch
Xem lại danh sách thuộc tính Giao dịch sau đây có trong Shopify Order Printer:
amountbuyer_pending_payment_instructionsbuyer_pending_payment_noticecreated_atgatewaygateway_display_nameidkindnamepayment_detailsreceiptshow_buyer_pending_payment_instructionsstatusstatus_label
Trường siêu dữ liệu
Một trường siêu dữ liệu được đính kèm vào đối tượng cha. Để tìm hiểu cách truy cập trường siêu dữ liệu trên một đối tượng cụ thể, tham khảo mục Truy cập trường siêu dữ liệu.
Trường siêu dữ liệu hỗ trợ nhiều loại dữ liệu, dùng để xác định loại thông tin được lưu trong trường siêu dữ liệu. Để truy cập trường siêu dữ liệu, đường dẫn truy cập cho trường siêu dữ liệu bao gồm hai lớp:
- không gian tên - nhóm các trường siêu dữ liệu để ngăn xung đột,
- khóa - tên trường siêu dữ liệu.
Do đó, bạn có thể truy cập đối tượng trường siêu dữ liệu bằng cú pháp sau: {{ resource.metafields.namespace.key }}.
Đặt tên: <object>.metafields.<namespace>.<key>. Ví dụ: order.metafields.shipping.express_delivery_status.
Loại:
StringArray- sử dụng[ ]để lập chỉ mục. Ví dụ:order.metafield.shipping.express_delivery_status[0]IntegerBooleanDate
Lưu ý Loại Metaobject không được hỗ trợ.
Các đối tượng hỗ trợ trường dữ liệu bổ sung:
OrderCustomerProductVariantLocation
Bộ lọc Liquid hiện có trong Shopify Order Printer
Cách sử dụng
Để áp dụng bộ lọc cho kết quả đầu ra, hãy thêm bộ lọc và bất kỳ thông số bộ lọc nào vào bên trong dấu ngoặc nhọn {{ }} của kết quả đầu ra, đứng sau ký tự gạch dọc |. Trong ví dụ bên dưới, product là đối tượng, title là thuộc tính và upcase là bộ lọc được áp dụng:
{{ product.title | upcase }}Nếu product.title có giá trị là Health potion, HEALTH POTION sẽ là kết quả đầu ra từ bộ lọc upcase.
Tham khảo phần Bộ lọc trong tài liệu tham khảo về Liquid của Chủ đề Shopify để biết chi tiết về cách sử dụng bộ lọc Liquid.
Bộ lọc áp dụng cho đối tượng Địa chỉ
format_address
Để xem ví dụ về cách sử dụng, hãy tham khảo tài liệu về Liquid của Chủ đề Shopify cho format_address.
Bộ lọc áp dụng cho mọi văn bản / chuỗi
camelcasecamelizeencode_url_componentformat_codehandlehighlightpad_spacesparagraphizepluralizeurl_escapeurl_param_escape
Để xem ví dụ về cách sử dụng, hãy tham khảo tài liệu về Liquid của Chủ đề Shopify cho bộ lọc chuỗi.
Bộ lọc áp dụng cho số tiền
moneymoney_with_currencymoney_without_currencymoney_without_trailing_zeros
Shopify Order Printer sử dụng các tùy chọn định dạng tiền tệ cho thông báo email được định cấu hình trong bảng điều khiển quản trị Shopify để định dạng tiền.
Bạn có thể thay đổi định dạng tiền tệ. Thiết lập giá trị Email kèm đơn vị tiền tệ và Email không kèm đơn vị tiền tệ trong bảng điều khiển quản trị Shopify để thay đổi định dạng của các bộ lọc tiền tệ trong Shopify Order Printer.
Để xem ví dụ về cách sử dụng, hãy tham khảo tài liệu về Liquid của Chủ đề Shopify cho bộ lọc tiền tệ.
Bộ lọc áp dụng để chuyển đổi đối tượng thành json
json
Để xem ví dụ về cách sử dụng, hãy tham khảo tài liệu về Liquid của Chủ đề Shopify cho bộ lọc json.
Bộ lọc áp dụng cho số thể hiện khối lượng
weightweight_with_unit
Để xem ví dụ về cách sử dụng, hãy tham khảo tài liệu về Liquid của Chủ đề Shopify cho khối lượng kèm đơn vị.
Bộ lọc áp dụng cho thẻ
highlight_active_taglink_to_add_taglink_to_remove_taglink_to_tag
Để xem ví dụ về cách sử dụng, hãy tham khảo tài liệu về Liquid của Chủ đề Shopify cho bộ lọc thẻ.
Bộ lọc áp dụng cho URL
article_img_urlasset_img_urlasset_urlcdn_asset_urlcollection_img_urlfile_img_urlfile_urlglobal_asset_urlimage_urlimg_tagimg_urllink_topayment_icon_png_urlpayment_type_img_urlpayment_type_svg_tagplaceholder_svg_tagproduct_img_urlscript_tagshopify_asset_urlstylesheet_tag
Để xem ví dụ sử dụng các bộ lọc phương tiện truyền thông được hỗ trợ, tham khảo tài liệu Liquid cho chủ đề Shopify về bộ lọc phương tiện truyền thông.
Bộ lọc áp dụng cho bộ sưu tập
link_to_typelink_to_vendorsort_byurl_for_typeurl_for_vendorwithin
Để xem các ví dụ sử dụng, hãy tham khảo tài liệu về Liquid của Chủ đề Shopify cho bộ lọc bộ sưu tập.