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 દિવસોની (432000 સેકન્ડ) તારીખ બનાવીએ છીએ અને પછી તેને ફૉર્મેટ કરીએ છીએ.

તમે "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 -%}