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는 여러 통화 체크아웃을 완벽하게 지원합니다. money 필터를 전달하기만 하면 활성 통화 형식을 사용하여 금액을 파싱하고 형식을 지정할 수 있습니다. 이 기능으로 통화가 자동으로 전환되지는 않습니다.

{{ checkout.total_price | money }}

카트 참고 사항

카트에 입력된 카트 참고 사항 값을 표시할 수 있습니다.

{{ checkout.note }}

카트 특성

배송 날짜와 같은 특정 카트 특성의 값을 표시하려면 이 코드 조각을 사용할 수 있습니다. Delivery date 키를 자신의 키에 맞게 변경해야 합니다.

{% 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일(432,000초) 후의 날짜를 생성한 다음 형식을 지정합니다.

날짜를 “02/24/2025” 형식으로 반환할 수 있습니다.

{% assign future_date = "now" | date: "%s" | plus: 432000 %}
{{ future_date | date: "%m/%d/%Y" }}

또는 날짜를 “Feb 24, 2025” 형식으로 지정할 수도 있습니다.

{% 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 }}

품목의 반복 총액 표시

일회성 할인 전 구독 품목의 반복 총액을 표시해야 하는 경우 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 -%}