Checkout Blocks의 블록에 지원되는 Liquid 구문
Checkout Blocks는 사용 가능한 여러 블록 유형에서 변수에 따라 결제 맞춤 설정을 개인화하는 데 사용할 수 있는 Liquid 구문의 하위 집합을 지원합니다.
지원되는 Liquid 변수
다음 목록에는 동적 콘텐츠 블록이나 품목 콘텐츠 블록 내에서 사용할 수 있는 지원되는 모든 Liquid 변수가 포함되어 있습니다. 일부 변수는 특정 결제 페이지에서만 액세스할 수 있으며, 다른 변수는 특정 블록 유형에만 포함될 수 있습니다.
각 변수에 대한 자세한 내용은 Shopify의 Liquid 객체 문서를 참조하세요.
결제 Liquid 변수
결제에 지원되는 Liquid 변수는 다음과 같습니다.
checkout.attributes
checkout.currency
checkout.has_selling_plan
checkout.item_count
checkout.line_items_subtotal_price
checkout.locale
checkout.market
checkout.metafields
checkout.note
checkout.requires_shipping
checkout.shipping_price
checkout.tax_price
checkout.total_price
고객 Liquid 변수
고객에 지원되는 Liquid 변수는 다음과 같습니다.
customer.id
customer.b2b
customer.full_name
customer.first_name
customer.last_name
customer.email
customer.phone
현지화 Liquid 변수
마켓에 지원되는 Liquid 변수는 다음과 같습니다.
localization.market
-localization.market.id
-localization.market.handle
주문 Liquid 변수
주문에 지원되는 Liquid 변수는 다음과 같습니다.
checkout.order.id
checkout.order.legacyResourceId
checkout.order.name
Shop Liquid 변수
스토어 정보에 지원되는 Liquid 변수는 다음과 같습니다.
shop.name
shop.url
품목 Liquid 변수
품목 변수는 품목 콘텐츠 블록 내에서만 액세스할 수 있습니다.
품목에 지원되는 Liquid 변수는 다음과 같습니다.
line_item.attributes
line_item.gift_card
line_item.has_selling_plan
line_item.line_price
line_item.line_level_discount_allocations
line_item.line_level_total_discount
line_item.options_with_values
line_item.price
line_item.product
-line_item.product.is_gift_card
-line_item.product.product_type
-line_item.product.requires_selling_plan
-line_item.product.tags
-line_item.product.vendor
line_item.quantity
line_item.requires_shipping
line_item.sku
line_item.subtitle
line_item.title
line_item.trigger
line_item.type
line_item.variant
-line_item.variant.available_for_sale
-line_item.variant.barcode
-line_item.variant.compare_at_price
-line_item.variant.id
-line_item.variant.price
-line_item.variant.price.amount
-line_item.variant.price.currency_code
-line_item.variant.requires_shipping
-line_item.variant.sku
-line_item.variant.title
-line_item.variant.unit_price
-line_item.variant.weight
-line_item.variant.weight_unit
line_item.variant_id
line_item.vendor
Liquid를 사용한 코드 조각 예
다음은 Checkout Blocks에서 지원하는 Liquid 코드 조각의 몇 가지 예입니다.
결제가 B2B인지 확인
결제가 B2B일 때만 콘텐츠를 표시할 수 있습니다.
{%- if customer.b2b -%}
B2B
{%- endif -%}
JSON 구문 분석
품목 특성(속성) 또는 메타 필드와 같은 JSON 값을 구문 분석할 수 있습니다.
{%- assign complex_json = checkout.metafields.checkoutblocks.complex | json -%}
통화 형식 지정
Checkout Blocks는 여러 통화의 결제를 완벽하게 지원합니다. 활성 통화 형식을 사용하여 금액 필터를 전달하여 금액을 구문 분석하고 형식을 지정하면 됩니다. 이렇게 해도 통화가 자동으로 변환되지는 않습니다.
{{ checkout.total_price | money }}
카트 참고 사항
카트 참고 사항의 값(예: 카트에 입력된 내용)을 표시할 수 있습니다.
{{ checkout.note }}
카트 특성
특정 카트 특성의 값(예: 배송 날짜)을 표시하기 위해 다음 코드 조각을 사용할 수 있습니다. 키 배송 날짜를 자신의 키와 일치하도록 변경해야 합니다.
{% assign delivery_date = '' %}
{% for attribute in checkout.attributes %}
{% if attribute.key == 'Delivery date' %}
{% assign delivery_date = attribute.value %}
{% endif %}
{% endfor %}
Delivery Date: {{ delivery_date }}
전체 결제 Liquid 콘텐츠 표시
결제 객체에 존재하는 값을 검토해야 하는 경우 JSON 필터를 사용하여 직렬화할 수 있습니다. 이는 디버깅 용도로만 사용해야 합니다.
{{ checkout | json }}
결제 메타 필드
결제 메타 필드를 참조하여 감사 및 주문 상태 페이지에 저장된 사용자 지정 필드를 표시할 수 있습니다. 메타 필드에 액세스에 대해 자세히 알아보세요.
블록에 정의된 대로 your-namespace
를 _네임스페이스_로 대체하고 your-custom-field-key
를 사용자 지정 필드 _키_로 대체하세요.
{{ checkout.metafields.your-namespace.your-custom-field-key.value }}
날짜 서식 지정
다음 예에서는 4일 후(43만2000초)의 날짜를 생성한 다음 서식을 지정합니다.
"02/24/2025"로 서식이 지정된 날짜를 반환할 수 있습니다.
{% assign future_date = "now" | date: "%s" | plus: 432000 %}
{{ future_date | date: "%m/%d/%Y" }}
또는 "2025년 2월 24일"로 날짜의 서식을 지정할 수 있습니다.
{% assign future_date = "now" | date: "%s" | plus: 432000 %}
{{ future_date | date: "%b %d, %Y" }}
Liquid에서 날짜 서식 지정에 대해 자세히 알아보세요.
품목 콘텐츠 맞춤 설정
다음은 품목 콘텐츠 블록에서 사용할 수 있는 Liquid 코드 조각의 몇 가지 예입니다.
조건부로 비교 가격 표시
다음 코드 조각을 사용하여 조건부로 품목의 비교 가격을 표시할 수 있습니다.
{%- if line_item.variant.compare_at_price.amount -%}
On sale. Originally {{ line_item.variant.compare_at_price.amount | times: line_item.quantity | money }}
{%- endif -%}
제품 태그에 따라 콘텐츠 표시
대소문자를 구분하는 제품 태그에 따라 조건부로 품목 콘텐츠를 표시할 수 있습니다.
{%- if line_item.product.tags contains 'final-sale' -%}
Final sale
{%- endif -%}
품목 특성(속성)
_품목 속성_이라고도 하는 품목 특성을 반복하여 배송 예상, 선주문 등의 정보를 표시할 수 있습니다.
{%- assign first_line_attribute = line_item.attributes | first -%}
{%- assign first_attribute_value = first_line_attribute.value | json_parse -%}
{%- assign message = first_attribute_value.message -%}
{%- if message -%}
{{ message }}
{%- endif -%}
"메타 필드 트리거" 값 표시
다음 코드에는 트리거의 값이 포함되어 있습니다.
{{ line_item.trigger }}
품목에 대한 정기요금 합계 표시
1회성 할인 전에 구독 품목의 정기요금 합계를 표시해야 하는 경우 line_level_total_discount
값을 사용할 수 있습니다.
{%- if line_item.line_level_total_discount > 0 and line_item.has_selling_plan -%}
Recurring total: {{ line_item.line_price | plus: line_item.line_level_total_discount | money }}
{%- endif -%}