ข้อมูลอ้างอิงตัวแปรและตัวกรอง Liquid ของ Shopify Order Printer
คุณสามารถใช้ Liquid เพื่อสร้างเทมเพลตที่คุณกำหนดเองได้โดยใช้แอป Shopify Order Printer เมื่อมี Liquid คุณจะสามารถสร้างเทมเพลตข้อความและแสดงผลเทมเพลตตามข้อมูลเฉพาะตัวของคำสั่งซื้อแต่ละรายการได้
ข้อมูลอ้างอิง Liquid ที่แสดงอยู่ในหน้านี้เป็นส่วนขยายของ Liquid เวอร์ชันโอเพนซอร์ซและมีไว้เพื่อใช้ในแอป Shopify Order Printer ในการแสดงผลข้อมูลตามคุณลักษณะ order
และ shop
คุณสามารถใช้รายการออบเจ็กต์ แท็ก และตัวกรองจากข้อมูลอ้างอิงนี้เพื่อปรับแต่งเทมเพลตของคุณ นอกจากนี้คุณยังสามารถใช้เอกสาร GraphQL API ของผู้ดูแลระบบ เพื่อดูรายละเอียดเกี่ยวกับช่องออบเจ็กต์ได้ด้วย
ในหน้านี้
การใช้ตัวแปรและคุณลักษณะ
ในเทมเพลต Shopify Order Printer ออบเจ็กต์ข้อมูลหลักคือ order
และ shop
คุณสามารถใช้ order.variable_name
เพื่อเข้าถึงคุณลักษณะคำสั่งซื้อได้
คุณลักษณะคำสั่งซื้อที่ใช้โดยทั่วไปหลายรายการต่อไปนี้สามารถเข้าถึงได้โดยไม่ต้องใช้คำนำหน้า order.
:
line_items
tax_lines
fulfillments
transactions
discounts
refunds
shipping_methods
customer
ตัวอย่างเช่น หากคุณต้องการเข้าถึงตัวแปรรายการสินค้า คุณสามารถใช้ line_items
หรือ order.line_items
ได้
ตัวแปร Liquid มีให้ใช้งานใน Shopify Order Printer
คลาสต่อไปนี้มีให้ใช้งาน โดยคุณลักษณะจะเรียงตามตัวอักษร
คำสั่งซื้อ
คุณลักษณะคำสั่งซื้อต่อไปนี้มีให้ใช้งานใน 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
. เวลาที่ประมวลผลการสั่งซื้อ ซึ่งเท่ากับorder.processed_at
จาก API GraphQL ใช้ตัวกรอง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
LineItem
ตรวจสอบรายการคุณลักษณะของ Line Item ต่อไปนี้ที่มีอยู่ใน 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
ตรวจสอบรายการคุณลักษณะของ DiscountApplication ต่อไปนี้ที่มีอยู่ใน Shopify Order Printer:
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 %}
- ดูข้อมูลเพิ่มเติมเกี่ยวกับประเภทส่วนลดและการใช้งานกับส่วนลดใน Liquid
DiscountAllocation
ตรวจสอบรายการคุณลักษณะของ DiscountAllocation ต่อไปนี้ที่มีอยู่ใน Shopify Order Printer:
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
ShippingLine
ตรวจสอบรายการคุณลักษณะของเส้นทางการจัดส่งต่อไปนี้ที่มีอยู่ใน Shopify Order Printer:
handle
id
original_price
price
. เลิกใช้งานเนื่องจากราคาไม่รวมส่วนลดระดับคำสั่งซื้อ คุณสมบัติshipping_line.price
ถูกแทนที่ด้วยshipping_line.price_with_discounts
แล้วprice_with_discounts
tax_lines
title
TaxLine
ตรวจสอบรายการคุณลักษณะของ Tax Line ต่อไปนี้ที่มีอยู่ใน 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
ตัวกรอง Liquid มีอยู่ใน Shopify Order Printer
การใช้
หากต้องการใช้ตัวกรองกับเอาต์พุต ให้เพิ่มตัวกรองและพารามิเตอร์ตัวกรองใดๆ ภายในวงเล็บปีกกาของเอาต์พุต {{ }}
นำหน้าด้วยเส้นขีดตั้ง |
ในตัวอย่างด้านล่าง สินค้าคือออบเจ็กต์ ชื่อคือคุณสมบัติของสินค้า และ upcase คือตัวกรองที่ถูกใช้:
{{ product.title | upcase }}
หาก product.title
มีค่าเป็น Health potion
, HEALTH POTION
จะเป็นเอาต์พุตจากตัวกรอง upcase
ดูส่วนตัวกรองจากข้อมูลอ้างอิง Liquid ของธีม Shopify หากต้องการทราบรายละเอียดเกี่ยวกับวิธีการใช้ตัวกรอง 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
หากต้องการตัวอย่างการใช้งาน ให้ดูตัวกรองสตริงในเอกสารประกอบเกี่ยวกับ Liquid ของธีม Shopify
ตัวกรองสำหรับใช้กับตัวเลขที่หมายถึงจำนวนเงิน
money
money_with_currency
money_without_currency
money_without_trailing_zeros
Shopify Order Printer ใช้ตัวเลือกการจัดรูปแบบสกุลเงินของการแจ้งเตือนทางอีเมลที่กําหนดค่าในส่วนผู้ดูแล Shopify เพื่อจัดรูปแบบเงิน คุณสามารถเปลี่ยนการจัดรูปแบบสกุลเงินได้ ตั้งค่า Email with currency
และค่า Email without currency
ในส่วนผู้ดูแล Shopify เพื่อเปลี่ยนการจัดรูปแบบตัวกรองเงินใน Shopify Order Printer
หากต้องการตัวอย่างการใช้งาน โปรดดูที่เอกสาร Shopify Themes Liquid สำหรับตัวกรองเงิน
ตัวกรองสำหรับใช้ในการแปลงออบเจ็กต์เป็น json
json
หากต้องการตัวอย่างการใช้งาน โปรดดูที่เอกสาร Shopify Themes Liquid สำหรับตัวกรอง json
ตัวกรองที่จะใช้กับตัวเลขที่มีความหมายเป็นน้ำหนัก
weight
weight_with_unit
หากต้องการตัวอย่างการใช้งาน ให้ดูน้ำหนักพร้อมหน่วยในเอกสารประกอบเกี่ยวกับ Liquid ของธีม Shopify
ตัวกรองที่จะใช้กับแท็ก
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
หากต้องการตัวอย่างการใช้งาน ให้ดูตัวกรองสื่อและ HTML ในเอกสารประกอบเกี่ยวกับ Liquid ของธีม Shopify
ตัวกรองสำหรับใช้ในคอลเลกชัน
link_to_type
link_to_vendor
sort_by
url_for_type
url_for_vendor
within
หากต้องการตัวอย่างการใช้งาน โปรดดูที่เอกสาร Shopify Themes Liquid สำหรับตัวกรองคอลเลกชัน