Shopify Flowમાં Liquid વેરિયેબલ્સનો ઉપયોગ કરવો

Liquid વેરિયેબલ્સ એ Liquidમાં વ્યાખ્યાયિત કરેલા પ્લેસહોલ્ડર છે જે વર્કફ્લો રન થાય ત્યારે GraphQL Admin APIના મૂલ્યોથી રિપ્લેસ થાય છે. વેરિયેબલ્સ તમારા વર્કફ્લોમાં શામેલ ગ્રાહકો, ઑર્ડર્સ અને પ્રોડક્ટ્સની વિશેષતાઓનું વર્ણન કરી શકે છે, જેમ કે ઑર્ડર નંબર, ઑર્ડરની કિંમત અથવા ગ્રાહકનું નામ. વેરિયેબલ્સનો ઉપયોગ તમારા વર્કફ્લોના લૉજિકને નિયંત્રિત કરવા માટે સ્થિતિઓમાં અથવા ક્રિયામાંથી ડેટા આઉટપુટ કરવા માટે થઈ શકે છે.

Liquidનો ઉપયોગ કરીને વર્કફ્લોમાં વેરિયેબલ્સ ઉમેરવા

તમે એક વેરિયેબલ ઉમેરો લિંક ધરાવતા કોઈપણ ટેક્સ્ટ ફીલ્ડમાં Liquidનો ઉપયોગ કરીને વેરિયેબલ્સ ઉમેરી શકો છો. સંબંધિત ફીલ્ડની નીચે એક વેરિયેબલ ઉમેરો લિંક પર ક્લિક કરો અને પછી સૂચિમાંથી કોઈ વેરિયેબલ પસંદ કરો.

આંતરિક ઇમેઇલ મોકલો ઍક્શનની કન્ફિગરેશન પેનલની ઇમેજ, જેમાં વિષય ફીલ્ડની નીચે 'વેરિયેબલ ઉમેરો' વિકલ્પ હાઇલાઇટ કરવામાં આવ્યો છે.

એક વેરિયેબલ ઉમેરો સૂચિમાંના વેરિયેબલ્સને ફિલ્ટર કરવામાં આવે છે, જેથી તમે ફક્ત એવા વેરિયેબલ્સનો જ ઉપયોગ કરો જે વર્તમાન પગલા પહેલાનાં પગલાઓ દ્વારા પરત કરવામાં આવ્યા હોય, જેમ કે ટ્રિગર્સ. ઉદાહરણ તરીકે, ઑર્ડર બનાવવામાં આવ્યો ટ્રિગર Admin API માંથી ઑર્ડર અને દુકાનનાં સંસાધનો પ્રદાન કરે છે જેને વેરિયેબલ્સ તરીકે દાખલ કરી શકાય છે. તમે સૂચિમાંથી વેરિયેબલ પસંદ કરો તે પછી, તેને ટેક્સ્ટ બૉક્સમાં યોગ્ય રીતે ફોર્મેટ કરેલા Liquid તરીકે ઉમેરવામાં આવે છે.

તમે સીધા ટેક્સ્ટ ફીલ્ડમાં પણ Liquid લખી શકો છો. ઉદાહરણ તરીકે, તમે order-123 જેવી Shopify ઍડમિનમાંથી ઑર્ડર સ્ટ્રિંગ ડિસ્પ્લે કરવા માટે {{ order.name }} વેરિયેબલનો ઉપયોગ કરી શકો છો.

કારણ કે Flow Liquid માટે વપરાતા ડેટાને પુનઃપ્રાપ્ત કરવા માટે Admin API નો ઉપયોગ કરે છે, તેથી વેરિયેબલ સિન્ટેક્સ કેમલ કેસ નો ઉપયોગ કરે છે. કેમલ કેસ વેરિયેબલ્સનો પહેલો શબ્દ લોઅરકેસ અક્ષરથી શરૂ થાય છે અને તે પછીના શબ્દો અપરકેસ અક્ષરથી શરૂ થાય છે, જેમ કે firstName અથવા canMarkAsPaid. ઉદાહરણ તરીકે, પ્રોડક્ટ બનાવવામાં આવી હતી તે તારીખને ઍક્સેસ કરવા માટે, {{ product.createdAt }} દાખલ કરો. જો તમે Shopify થીમમાં Liquid સિન્ટેક્સનો ઉપયોગ કરો છો, જે કેમલ કેસનો ઉપયોગ કરતું નથી, તો પછી તમે {{ product.created_at }} દાખલ કરશો.

શરતી અને ઇટરેશન Liquid ટૅગ્સ

નીચેના ફંક્શન્સ કરવા માટે વેરિયેબલ્સ સાથે Liquid ટૅગ્સનો ઉપયોગ કરી શકાય છે:

  • શરતી સ્ટેટમેન્ટ્સ લખો, જેમ કે ઑર્ડરનું કુલ મૂલ્ય $100 કરતાં વધુ છે કે નહીં તે નિર્ધારિત કરવું.
  • ઑબ્જેક્ટ્સની સૂચિ મારફતે ઇટરેટ કરો, જેમ કે ઑર્ડરમાં દરેક લાઇન આઇટમ માટે ડેટા આઉટપુટ કરવો.

તમે આ સ્ટેટમેન્ટ્સ લખવા અને ઑબ્જેક્ટ્સ મારફતે ઇટરેટ કરવા માટે Liquid ટૅગ્સ નો ઉપયોગ કરી શકો છો.

ઉદાહરણ તરીકે, જો ઑર્ડરનું કુલ મૂલ્ય $100 કરતાં વધુ હોય, તો નીચેનું Liquid ઑર્ડર નંબર ડિસ્પ્લે કરે છે:

{% if order.totalPriceSet.shopMoney.amount > 100 %}
  Order number: {{ order.name }}
{% endif %}

તમે ઑબ્જેક્ટ્સની સૂચિ મારફતે ઇટરેટ કરવા માટે for લૂપ નો પણ ઉપયોગ કરી શકો છો, જેમ કે ઑર્ડર માટે લાઇન આઇટમ્સ. ઉદાહરણ તરીકે, નીચેનું Liquid ઑર્ડરમાં દરેક લાઇન આઇટમનું નામ ડિસ્પ્લે કરે છે:

{% for li in order.lineItems %}
  {{ li.title }}
{% endfor %}

Flow નીચેના Liquid શરતી (અથવા કંટ્રોલ ફ્લો) ટૅગ્સને સપોર્ટ કરે છે:

Flow નીચેના Liquid ઇટરેશન ટૅગ્સને પણ સપોર્ટ કરે છે:

વેરિયેબલ્સમાં ફિલ્ટર્સ લાગુ કરવા

તમે ફિલ્ટર્સનો ઉપયોગ કરીને Liquidમાં વેરિયેબલ ડેટાને રૂપાંતરિત કરી શકો છો. Flow તમામ ઓપન સોર્સ Liquid ફિલ્ટર્સ ને સપોર્ટ કરે છે.

ઉદાહરણ તરીકે, નીચેનું Liquid ઑર્ડરના નામમાંથી પ્રીફિક્સ હટાવે છે અને જે બાકી રહે તે આઉટપુટ કરે છે: {{ order.name | remove: "Order-" }}

ફિલ્ટર્સમાં Liquid વેરિયેબલ્સનો ઉપયોગ કરવા માટેની વિચારણાઓ

ફિલ્ટર્સનો ઉપયોગ કરીને વેરિયેબલ્સને રૂપાંતરિત કરતા પહેલા, નીચેની વિચારણાઓ રિવ્યૂ કરો:

  • Flow કેટલાક ફિલ્ટર્સ માટે ઉપલબ્ધ ડૉટ નોટેશનને સપોર્ટ કરતું નથી. ઉદાહરણ તરીકે, Flow {{ order.lineItems | size }} ને સપોર્ટ કરે છે પરંતુ {{ order.lineItems.size }} ને નહીં.
  • Flow મેટાફીલ્ડ્સ માટે ડૉટ નોટેશનને સપોર્ટ કરતું નથી. ઉદાહરણ તરીકે, તમે {{ order.metafields.custom.hold_note }} નો ઉપયોગ કરી શકતા નથી. તેના બદલે, તમારે ઉદાહરણોમાં વર્ણવ્યા પ્રમાણે મેટાફીલ્ડ્સ પર લૂપ કરવું આવશ્યક છે.
  • Flow સૂચિમાંની આઇટમ્સને ઍક્સેસ કરવા માટે ઇન્ડેક્સનો ઉપયોગ કરવાનું સપોર્ટ કરતું નથી. ઉદાહરણ તરીકે, તમે {{ order.lineItems[0].title }} નો ઉપયોગ કરી શકતા નથી. તેના બદલે, તમારે ઉદાહરણોમાં વર્ણવ્યા પ્રમાણે લાઇન આઇટમ્સ પર લૂપ કરવું આવશ્યક છે.

તારીખનાં ફિલ્ટર્સ

સ્ટાન્ડર્ડ Liquid ફિલ્ટર્સ ઉપરાંત, Flow નિર્ધારિત સમય ટ્રિગર અને ડેટા મેળવો સુવિધાઓને સપોર્ટ કરવા માટે બીજી તારીખની સાપેક્ષમાં કોઈ તારીખ મેળવવા માટે તારીખ ફિલ્ટર્સ પ્રદાન કરે છે. આ ફિલ્ટર્સ છે: date_minus અને date_plus. ઉદાહરણ તરીકે:

  • ભવિષ્યમાં એક દિવસ પછીની તારીખ પરત કરવા માટે: {{ "now" | date_plus: "1 day" }}
  • ભૂતકાળમાં એક દિવસ પહેલાંની તારીખ પરત કરવા માટે: {{ "now" | date_minus: "1 day" }}

આ ફિલ્ટર્સ અવધિના એકમ તરીકે એકવચન (જેમ કે second) અને બહુવચન (જેમ કે seconds) એમ બંને રૂપે second, minute, day, week, month અને year સ્વીકારે છે. તમે નીચેના પ્રકારના કસ્ટમાઇઝ કરી શકાય તેવા એકમો પણ સપ્લાય કરી શકો છો:

  • સેકંડ્સની સંખ્યા દર્શાવતો ઇન્ટિજર: {{ "now" | date_minus: 3600 }}, જ્યાં 3600 એ 1 કલાકની સમકક્ષ છે.
  • ISO8601 અવધિ સ્ટ્રિંગ: {{ "now" | date_minus: "P1Y2D" }}, જ્યાં P1Y2D નો અર્થ 1 વર્ષ અને 2 દિવસ થાય છે.

ક્રિપ્ટોગ્રાફિક ફિલ્ટર્સ

Flow હૅશિંગ અને હૅશ-આધારિત મેસેજ ઑથેન્ટિકેશન કોડ્સ (HMACs) બનાવવા માટે ક્રિપ્ટોગ્રાફિક ફિલ્ટર્સ પ્રદાન કરે છે. આ ફિલ્ટર્સ અનન્ય ઓળખકર્તાઓ, ચેકસમ્સ બનાવવા અથવા ચોક્કસ હૅશ ફૉર્મેટની જરૂર હોય તેવી તૃતીય-પક્ષ સિસ્ટમ્સ સાથે એકીકૃત કરવા માટે ઉપયોગી છે.

હૅશિંગ ફિલ્ટર્સ

Shopify Flow નીચેના પ્રકારના હૅશિંગ ફિલ્ટર્સને સપોર્ટ કરે છે:

  • blake3 - BLAKE3 હૅશ બનાવે છે (સામાન્ય ઉપયોગ માટે ભલામણ કરેલ).
  • sha256 - SHA-256 હૅશ બનાવે છે.
  • sha1 - SHA-1 હૅશ બનાવે છે.
  • md5 - MD5 હેશ બનાવે છે.

સામાન્ય હેશિંગના હેતુઓ અને નવા અમલીકરણો માટે, તમારે blake3 નો ઉપયોગ કરવો જોઈએ, કારણ કે તે જૂના અલ્ગોરિધમ્સની તુલનામાં બહેતર પ્રદર્શન અને સુરક્ષા પ્રદાન કરે છે. જોકે, તૃતીય-પક્ષ સિસ્ટમ્સ સાથે સુસંગતતા માટે sha256, sha1 અને md5 ઉપલબ્ધ છે.

ઉપયોગનું ઉદાહરણ: {{ "hello world" | blake3 }} "hello world" નો BLAKE3 હેશ પાછો આપે છે.

HMAC ફિલ્ટર્સ

સિક્રેટ કી સાથે HMAC બનાવવા માટે, નીચેનામાંથી કોઈ એક સમર્થિત ફિલ્ટરનો ઉપયોગ કરો:

ઉપયોગનું ઉદાહરણ:

  • બેઝિક: {{ "message" | hmac_sha256: "secret_key" }}
  • સિક્રેટ્સ સાથે (ભલામણ કરેલ): {{ "message" | hmac_sha256: secrets.api_key }}

Shopify Flow માં Liquid સાથે વેરિયેબલ્સનો ઉપયોગ કરવાના ઉદાહરણો

Liquid વેરિયેબલ્સનો ઉપયોગ કેવી રીતે કરવો તેની વધુ સારી સમજ મેળવવા માટે, નીચેના ઉદાહરણો જુઓ:

સંસાધનો માટે આઉટપુટ URLs

તમે વર્કફ્લોમાં શામેલ ગ્રાહક, ઑર્ડર અને પ્રોડક્ટ માટે URLs નું આઉટપુટ આપવા માગો છો.

# Output the base Admin URL for your store
https://admin.shopify.com/store/{{ shop.myShopifyDomain | replace: ".myshopify.com", "" }}

# Assign the base Admin url to a variable named base_url:
{%- capture base_url -%}https://admin.shopify.com/store/{{ shop.myShopifyDomain | replace: ".myshopify.com", "" }}{%- endcapture -%}

# Customer from a Customer trigger:
{{ base_url }}/customers/{{ customer.legacyResourceId }}

# Customer without the base_url:
https://admin.shopify.com/store/{{ shop.myShopifyDomain | replace: ".myshopify.com", "" }}/customers/{{ customer.legacyResourceId }}

# Customer from an Order trigger:
{{ base_url }}/customers/{{ order.customer.legacyResourceId }}

# Order:
{{ base_url }}/orders/{{ order.legacyResourceId }}

# Product:
{{ base_url }}/products/{{ product.legacyResourceId }}

# Product Variant:
{{ base_url }}/products/{{ product.legacyResourceId }}/variants/{{ productVariant.legacyResourceId }}

# Example showing a clickable link in HTML, making use of the URL:
<a href="{{ base_url }}/products/{{ product.legacyResourceId }}">{{ product.title }}</a>

ટૅગના લિસ્ટને મેટાફીલ્ડમાં રૂપાંતરિત કરો

તમે ટૅગના સેટને મેટાફીલ્ડમાં રૂપાંતરિત કરવા માગો છો જે સિંગલ-લાઇન ટેક્સ્ટ ફીલ્ડ્સનું લિસ્ટ હોય. તમે સ્ટોરમાં પ્રોડક્ટ ઉમેરવામાં આવી ટ્રિગરનો ઉપયોગ કરીને વર્કફ્લો બનાવો છો, અને પ્રોડક્ટ મેટાફીલ્ડ અપડેટ કરો ઍક્શનનો ઉપયોગ કરો છો. પ્રોડક્ટ મેટાફીલ્ડ અપડેટ કરો ઍક્શનના વેલ્યૂ વિભાગમાં, તમે નીચેનો લિક્વિડ કોડ ઉમેરો છો. આ ઉદાહરણ માની લે છે કે જ્યારે પ્રોડક્ટ બનાવવામાં આવે ત્યારે તમારે માત્ર એક જ વાર વેલ્યૂ સેટ કરવાની જરૂર છે, અને પ્રોડક્ટમાં બે સંબંધિત ટૅગ છે: color:red અને color:orange.

સિંગલ-લાઇન ટેક્સ્ટ ફીલ્ડના લિસ્ટને સેટ કરવા માટે લિક્વિડનું ઉદાહરણ.
ઇનપુટઆઉટપુટ
{% capture mf_value %}
{%- for tags_item in product.tags -%}
  {%- if tags_item contains "color:" -%}
    "{{- tags_item | remove_first: "color:" | strip -}}",
  {%- endif -%}
{%- endfor -%}
{% endcapture -%}
[{{mf_value | remove_last: ","}}]
      
["red","orange"]

ઑર્ડર માટે ડાયનેમિક ઇમેઇલ મેસેજ લખો

જ્યારે કોઈ ગ્રાહક ઑર્ડર પર $500 કરતાં વધુ ખર્ચ કરે ત્યારે તમે કર્મચારીને ઇમેઇલ મોકલવા માટે વર્કફ્લો બનાવવા માગો છો. તમે ઑર્ડર બનાવવામાં આવ્યો ટ્રિગરનો ઉપયોગ કરીને વર્કફ્લો બનાવો છો, એવી સ્થિતિ સેટ કરો છો કે જો ઑર્ડરની કુલ રકમ $500 થી વધુ હોય તો તે સાચી હોય, અને આંતરિક ઇમેઇલ મોકલો ઍક્શનનો ઉપયોગ કરો છો. આંતરિક ઇમેઇલ મોકલો ઍક્શનના મેસેજ વિભાગમાં, તમે નીચેના વેરિયેબલ્સનો ઉપયોગ કરો છો.

ગ્રાહકની વિગતો પ્રદાન કરવા માટે વેરિયેબલના ઉપયોગનું ઉદાહરણ.
ઇનપુટઆઉટપુટ
Please send a personal thank you note to {{ order.customer.firstName }} {{ order.customer.lastName }}({{ order.customer.email }}) for placing an order for $ {{ order.totalPriceSet.shopMoney.amount }}.
$763.42 નો ઑર્ડર આપવા બદલ કૃપા કરીને જિયાને ડ્યુપોન્ટ (jeanne@example.com) ને આભાર માનતી વ્યક્તિગત નોંધ મોકલો.

ઓછો સ્ટૉક ધરાવતી પ્રોડક્ટ માટે ડાયનેમિક ઇમેઇલ મેસેજ લખો

તમે નક્કી કરો છો કે જ્યારે પ્રોડક્ટની ઇન્વેન્ટરી ઓછી થઈ રહી હોય અને વધુ સ્ટૉક માટે ઑર્ડર આપવાની જરૂર હોય ત્યારે તમારે સ્ટાફના સભ્યને જાણ કરવાની જરૂર છે. તમે ઇન્વેન્ટરીનો જથ્થો બદલાયો ટ્રિગરથી શરૂ થતો વર્કફ્લો બનાવો છો, અને એક સ્થિતિ સેટ કરો છો જે સાચી હોય જો અગાઉની ઇન્વેન્ટરીનો જથ્થો 10 કરતા ઓછો અથવા તેના બરાબર હોય. આંતરિક ઇમેઇલ મોકલો ઍક્શનના મેસેજ વિભાગમાં, તમે નીચેના વેરિયેબલ્સનો ઉપયોગ કરો છો.

આઇટમની વિગતો પ્રદાન કરવા માટે વેરિયેબલના ઉપયોગનું ઉદાહરણ.
ઇનપુટઆઉટપુટ
Please reorder {{ product.title }}. Email owner@store.com to verify that they've received the purchase order.
કૃપા કરીને High Waist Leggings - Black ને રિઑર્ડર કરો. તેમને ખરીદી ઑર્ડર મળ્યો છે કે નહીં તે ચકાસવા માટે owner@example.com પર ઇમેઇલ કરો.

સ્ટાફને છેતરપિંડીવાળા ઑર્ડર વિશે સૂચિત કરવા માટે ડાયનેમિક ઇમેઇલ મેસેજ લખો

તમે એવા ઑર્ડર કૅન્સલ કરવા માગો છો જે ઉચ્ચ જોખમ સ્તર ધરાવે છે, પરંતુ તમે ઇચ્છો છો કે તમારો સ્ટાફ ઑર્ડરને મેન્યુઅલી કૅન્સલ કરે. તમે ઑર્ડર બનાવવામાં આવ્યો ટ્રિગરથી શરૂ થતો વર્કફ્લો બનાવો છો, અને એક સ્થિતિ સેટ કરો છો જે સાચી હોય જો ઑર્ડરનું જોખમ સ્તર ઉચ્ચ હોય. આંતરિક ઇમેઇલ મોકલો ઍક્શનના મેસેજ વિભાગમાં, તમે નીચેના વેરિયેબલ્સનો ઉપયોગ કરો છો.

છેતરપિંડીવાળા ઑર્ડર વિશે માહિતી પ્રદાન કરવા માટે વેરિયેબલના ઉપયોગનું ઉદાહરણ.
ઇનપુટઆઉટપુટ
Our Shopify store has received an order with a high risk of fraud. We would like to cancel this order right away, before it is sent to production:
{{ order.name }} {{ order.billingAddress.lastName }}, {{ order.billingAddress.firstName }} {{ order.email }}
Please confirm the new order status. Thanks!
અમારા Shopify સ્ટોરને છેતરપિંડીના ઉચ્ચ જોખમ સાથેનો ઑર્ડર મળ્યો છે. અમે આ ઑર્ડર પ્રોડક્શન માટે મોકલવામાં આવે તે પહેલાં, તરત જ તેને કૅન્સલ કરવા માગીએ છીએ:

#1001
ડ્યુપોન્ટ, જિયાને
jeanne@example.com

કૃપા કરીને નવા ઑર્ડરની સ્થિતિ કન્ફર્મ કરો. આભાર!

for લૂપનો ઉપયોગ કરીને ઑર્ડર માટે લાઇન આઇટમનું આઉટપુટ આપો

જ્યારે ઑર્ડર પ્રાપ્ત થાય છે, ત્યારે ઑર્ડર કરાયેલ પ્રોડક્ટ સમાવતો મેસેજ મોકલવો ઉપયોગી થઈ શકે છે. તમે for loop નો ઉપયોગ કરીને આ કરી શકો છો, જે વારંવાર કોડના બ્લૉકને એક્ઝિક્યુટ કરે છે. વેરિયેબલ્સને સમર્થન આપતા ટેક્સ્ટ ફીલ્ડ્સ for લૂપ્સ અને forloop ઑબ્જેક્ટ ને પણ સમર્થન આપે છે.

ઉદાહરણ તરીકે, તમે એવો વર્કફ્લો બનાવવા માગો છો જે ઑર્ડરમાં રહેલા તમામ SKUs અને જથ્થાઓનું લિસ્ટ આપે. આંતરિક ઇમેઇલ મોકલો ઍક્શનના મેસેજ વિભાગમાં, તમે નીચેના વેરિયેબલ્સનો ઉપયોગ કરો છો.

ઑર્ડરની માહિતી પ્રદાન કરવા માટે for લૂપના ઉપયોગનું ઉદાહરણ.
ઇનપુટઆઉટપુટ
Order summary:
{% for a in order.lineItems %}
  {{a.sku}} ( {{a.quantity}} )
{% endfor %}
ઑર્ડરનો સારાંશ:
8987097979 (50)
8877778887 (3)
888998898B (1)

વધારાની માહિતી સાથે for લૂપનો ઉપયોગ કરીને ઑર્ડર માટે લાઇન આઇટમનું આઉટપુટ આપો

તમે ઇમેઇલમાં વધુ માહિતી ઉમેરવાનું નક્કી કરો છો, જેમાં પ્રોડક્ટનું નામ, SKUs, આઇટમ દીઠ કિંમત અને ગ્રાહકની શિપિંગ માહિતી શામેલ છે. આંતરિક ઇમેઇલ મોકલો ઍક્શનના મેસેજ વિભાગમાં, તમે નીચેના વેરિયેબલ્સનો ઉપયોગ કરો છો.

વધુ વ્યાપક ઑર્ડરની માહિતી આપવા માટે 'for લૂપ'ના ઉપયોગનું ઉદાહરણ.
ઇનપુટઆઉટપુટ
Order summary:
{% for a in order.lineItems %}
  Product: {{a.title}}
  SKU: {{a.sku}}
  Price (per unit): ${{a.originalUnitPriceSet.shopMoney.amount}}
  Quantity: {{a.quantity}}
{% endfor %}
ઑર્ડરનો સારાંશ:
પ્રોડક્ટ: હાઈ વેસ્ટ લેગિંગ્સ - Black
SKU: 8987097979
કિંમત (પ્રતિ યુનિટ): $8.49
જથ્થો: 5
પ્રોડક્ટ: એથ્લેટિક સૉક્સ - Blue
SKU: 888998898B
કિંમત (પ્રતિ યુનિટ): $5.61
જથ્થો: 2

if સ્ટેટમેન્ટ સાથે for લૂપને જોડીને કેટલીક લાઇન આઇટમ આઉટપુટ કરો

તમારે કોઈ ચોક્કસ વિક્રેતા દ્વારા સપ્લાય કરાયેલી વેચાયેલી આઇટમ ટ્રેક કરવાની જરૂર છે. આંતરિક ઇમેઇલ મોકલો ઍક્શનના મેસેજ વિભાગમાં, તમે નીચેના ચલોનો ઉપયોગ કરો છો અને તમારા for લૂપમાં if સ્ટેટમેન્ટ શામેલ કરો છો.

ચોક્કસ વિક્રેતાઓ માટે ઑર્ડરની માહિતી આપવા માટે 'for લૂપ' અને 'if સ્ટેટમેન્ટ'ના ઉપયોગનું ઉદાહરણ.
ઇનપુટઆઉટપુટ
Acme product sold:
{% for x in order.lineItems %}
  {% if x.vendor == 'acme-vendor' %}
    Product name: {{x.title}}
    SKU: {{x.sku}}
  {% endif %}
{% endfor %}
Acme પ્રોડક્ટ વેચાઈ:
પ્રોડક્ટનું નામ: હાઈ વેસ્ટ લેગિંગ્સ - Black
SKU: 8987097979

Shopify Flow માં જટિલ ડેટા ઑબ્જેક્ટ

Flow તમને GraphQL Admin API માં હોય તેવા લગભગ કોઈ પણ ડેટાને ઍક્સેસ કરવાની મંજૂરી આપે છે. આમાં સૂચિઓ અને ઑબ્જેક્ટ જેવા જટિલ ડેટા ઑબ્જેક્ટનો સમાવેશ થાય છે. જોકે, આ ઑબ્જેક્ટ સાથે તમે જે કરી શકો છો તેની કેટલીક મર્યાદાઓ છે. આ વિભાગ આ મર્યાદાઓની રૂપરેખા આપે છે અને તેમની સાથે કેવી રીતે કામ કરવું તેના ઉદાહરણ પૂરા પાડે છે.

સૂચિઓ અને ઑબ્જેક્ટને સીધા કૉલ કરવાને બદલે, તમારે સૂચિ પર લૂપ કરવું જોઈએ અને માત્ર તમને જોઈતાં ફીલ્ડ શામેલ કરવાં જોઈએ.

ઉદાહરણ તરીકે, {{ order.lineItems }} ને સીધા કૉલ કરવાને બદલે, ચોક્કસ ફીલ્ડ કૉલ કરવા માટે નીચેના ફોર્મેટનો ઉપયોગ કરો. આ ઉદાહરણોમાં એવાં તમામ ફીલ્ડ શામેલ છે જે સૂચિ અથવા ઑબ્જેક્ટને સીધા કૉલ કરીને શામેલ કરવામાં આવશે. તમને જોઈતાં ફીલ્ડ કૉપિ કરો અને પેસ્ટ કરો.

ટેક્સ્ટ
{% for li in order.lineItems %}
    {% comment %}li.contract - omitted{% endcomment %}

{% for ca in li.customAttributes %}
    {{ ca.key }}
    {{ ca.value }}
{% endfor %}

{% for da in li.discountAllocations %}
    {{ da.allocatedAmountSet.presentmentMoney.amount }}
    {{ da.allocatedAmountSet.presentmentMoney.currencyCode }}
    {{ da.allocatedAmountSet.shopMoney.amount }}
    {{ da.allocatedAmountSet.shopMoney.currencyCode }}
{% endfor %}

{{ li.discountedTotalSet.presentmentMoney.amount }}
{{ li.discountedTotalSet.presentmentMoney.currencyCode }}
{{ li.discountedTotalSet.shopMoney.amount }}
{{ li.discountedTotalSet.shopMoney.currencyCode }}

{{ li.discountedUnitPriceSet.presentmentMoney.amount }}
{{ li.discountedUnitPriceSet.presentmentMoney.currencyCode }}
{{ li.discountedUnitPriceSet.shopMoney.amount }}
{{ li.discountedUnitPriceSet.shopMoney.currencyCode }}

{% comment %}li.duties - omitted {% endcomment %}

{{ li.fulfillableQuantity }}

{{ li.fulfillmentService.callbackUrl }}
{{ li.fulfillmentService.fulfillmentOrdersOptIn }}
{{ li.fulfillmentService.handle }}
{{ li.fulfillmentService.id }}
{{ li.fulfillmentService.inventoryManagement }}
{% comment %}rest of location omitted{% endcomment %}
{{ li.fulfillmentService.location.name }}
{{ li.fulfillmentService.productBased }}
{{ li.fulfillmentService.serviceName }}
{% for sm in li.fulfillmentService.shippingMethods %}
    {{ sm.code }}
    {{ sm.label }}
{% endfor %}
{{ li.fulfillmentService.type }}

{{ li.fulfillmentStatus }}
{{ li.id }}

{{ li.image.altText }}
{{ li.image.height }}
{{ li.image.id }}
{% comment %}li.image.metafield omitted{% endcomment %}
{% comment %}li.image.privateMetafield omitted{% endcomment %}
{{ li.image.width }}

{{ li.merchantEditable }}
{{ li.name }}
{{ li.nonFulfillableQuantity }}

{{ li.originalTotalSet.presentmentMoney.amount }}
{{ li.originalTotalSet.presentmentMoney.currencyCode }}
{{ li.originalTotalSet.shopMoney.amount }}
{{ li.originalTotalSet.shopMoney.currencyCode }}

{{ li.originalUnitPriceSet.presentmentMoney.amount }}
{{ li.originalUnitPriceSet.presentmentMoney.currencyCode }}
{{ li.originalUnitPriceSet.shopMoney.amount }}
{{ li.originalUnitPriceSet.shopMoney.currencyCode }}

{% comment %}rest of product omitted{% endcomment %}
{{ li.product.title }}

{{ li.quantity }}
{{ li.refundableQuantity }}
{{ li.requiresShipping }}
{{ li.restockable }}

{{ li.sellingPlan.name }}

{{ li.sku }}

{% for tl in li.taxLines %}
    {{ tl.priceSet.presentmentMoney.amount | json }}
    {{ tl.priceSet.presentmentMoney.currencyCode | json }}
    {{ tl.priceSet.shopMoney.amount | json }}
    {{ tl.priceSet.shopMoney.currencyCode | json }}
    {{ tl.rate | json }}
    {{ tl.ratePercentage | json }}
    {{ tl.title | json }}
{% endfor %}

{{ li.taxable }}
{{ li.title }}

{{ li.totalDiscountSet.presentmentMoney.amount }}
{{ li.totalDiscountSet.presentmentMoney.currencyCode }}
{{ li.totalDiscountSet.shopMoney.amount }}
{{ li.totalDiscountSet.shopMoney.currencyCode }}

{{ li.unfulfilledDiscountedTotalSet.presentmentMoney.amount }}
{{ li.unfulfilledDiscountedTotalSet.presentmentMoney.currencyCode }}
{{ li.unfulfilledDiscountedTotalSet.shopMoney.amount }}
{{ li.unfulfilledDiscountedTotalSet.shopMoney.currencyCode }}

{{ li.unfulfilledOriginalTotalSet.presentmentMoney.amount }}
{{ li.unfulfilledOriginalTotalSet.presentmentMoney.currencyCode }}
{{ li.unfulfilledOriginalTotalSet.shopMoney.amount }}
{{ li.unfulfilledOriginalTotalSet.shopMoney.currencyCode }}

{{ li.unfulfilledQuantity }}

{% comment %}rest of variant omitted{% endcomment %}
{{ li.variant.title }}

{{ li.variantTitle }}
{{ li.vendor }}

{% endfor %}

json
{
    "lineItems": [
        {% for li in order.lineItems %}
            {% if forloop.first != true %},{% endif %}
        {
            "contract": {
                {% comment %}rest of contract omitted{% endcomment %}
                "id": {{ li.contract.id | json }}
            },
            "customAttributes": [
                {% for ca in li.customAttributes %}
                    {% if forloop.first != true %},{% endif %}
                    {
                        "key":{{ ca.key | json }},
                        "value":{{ ca.value | json }}
                    }
                {% endfor %}
            ],
&#x22;discountAllocations&#x22;: [
            {% for da in li.discountAllocations %}
                {% if forloop.first != true %},{% endif %}
                &#x22;allocatedAmountSet&#x22;: {
                    &#x22;presentmentMoney&#x22; : {
                        &#x22;amount&#x22;: {{ da.allocatedAmountSet.presentmentMoney.amount | json }},
                        &#x22;currencyCode&#x22;: {{ da.allocatedAmountSet.presentmentMoney.currencyCode | json }}
                    },
                    &#x22;shopMoney&#x22;: {
                        &#x22;amount&#x22;: {{ da.allocatedAmountSet.shopMoney.amount | json }},
                        &#x22;currencyCode&#x22;: {{ da.allocatedAmountSet.shopMoney.currencyCode | json }}
                    }
                }
            {% endfor %}
        ],

        &#x22;discountedTotalSet&#x22;: {
            &#x22;presentmentMoney&#x22; : {
                &#x22;amount&#x22;: {{ li.discountedTotalSet.presentmentMoney.amount | json }},
                &#x22;currencyCode&#x22;: {{ li.discountedTotalSet.presentmentMoney.currencyCode | json }}
            },
            &#x22;shopMoney&#x22;: {
                &#x22;amount&#x22;: {{ li.discountedTotalSet.shopMoney.amount | json }},
                &#x22;currencyCode&#x22;: {{ li.discountedTotalSet.shopMoney.currencyCode | json }}
            }
        },

        &#x22;discountedUnitPriceSet&#x22;: {
            &#x22;presentmentMoney&#x22; : {
                &#x22;amount&#x22;: {{ li.discountedUnitPriceSet.presentmentMoney.amount | json }},
                &#x22;currencyCode&#x22;: {{ li.discountedUnitPriceSet.presentmentMoney.currencyCode | json }}
            },
            &#x22;shopMoney&#x22;: {
                &#x22;amount&#x22;: {{ li.discountedUnitPriceSet.shopMoney.amount | json }},
                &#x22;currencyCode&#x22;: {{ li.discountedUnitPriceSet.shopMoney.currencyCode | json }}
            }
        },
        &#x22;duties&#x22;: [
            {% for duty li.duties %}
            {% if forloop.first != true %},{% endif %}
            {
                {% comment %}rest of duties omitted{% endcomment %}
                &#x22;id&#x22;: {{ duty.id | json }}
            }
            {% endfor %}
        ],
        &#x22;fulfillableQuantity&#x22;: {{ li.fulfillableQuantity | json }},

        &#x22;fulfillmentService&#x22;: {
            &#x22;callbackUrl&#x22;:{{ li.fulfillmentService.callbackUrl | json }},
            &#x22;fulfillmentOrdersOptIn&#x22;: {{ li.fulfillmentService.fulfillmentOrdersOptIn | json }},
            &#x22;handle&#x22;: {{ li.fulfillmentService.handle | json }},
            &#x22;id&#x22;: {{ li.fulfillmentService.id | json }},
            &#x22;inventoryManagement&#x22;: {{ li.fulfillmentService.inventoryManagement | json }},
            {% comment %}fulfillmentService.inventoryManagement - omitted {% endcomment %}
            &#x22;productBased&#x22;: {{ li.fulfillmentService.productBased | json }},
            &#x22;serviceName&#x22;: {{ li.fulfillmentService.serviceName | json }},
            &#x22;shippingMethods&#x22;: [
                {% for sm in li.fulfillmentService.shippingMethods %}
                    {% if forloop.first != true %},{% endif %}
                    {
                        &#x22;code&#x22;: {{ sm.code | json }},
                        &#x22;label&#x22;: {{ sm.label | json }}
                    }
                {% endfor %}
            ],
            &#x22;type&#x22;: {{ li.fulfillmentService.type | json }}

        },
        &#x22;fulfillmentStatus&#x22;: {{ li.fulfillmentStatus | json }},
        &#x22;id&#x22;: {{ li.id | json }},
        &#x22;image&#x22;: {
            &#x22;altText&#x22;: {{ li.image.altText | json }},
            &#x22;height&#x22;: {{ li.image.height | json }},
            &#x22;id&#x22;: {{ li.image.id | json }},
            {% comment %}li.image.metafield omitted{% endcomment %}
            {% comment %}li.image.privateMetafield omitted{% endcomment %}
            &#x22;width&#x22;:{{ li.image.width | json }}
        },
        &#x22;merchantEditable&#x22;: {{ li.merchantEditable | json }},
        &#x22;name&#x22;: {{ li.name | json }},
        &#x22;nonFulfillableQuantity&#x22;: {{ li.nonFulfillableQuantity | json }},

        &#x22;originalTotalSet&#x22;: {
            &#x22;presentmentMoney&#x22; : {
                &#x22;amount&#x22;: {{ li.originalTotalSet.presentmentMoney.amount | json }},
                &#x22;currencyCode&#x22;: {{ li.originalTotalSet.presentmentMoney.currencyCode | json }}
            },
            &#x22;shopMoney&#x22;: {
                &#x22;amount&#x22;: {{ li.originalTotalSet.shopMoney.amount | json }},
                &#x22;currencyCode&#x22;: {{ li.originalTotalSet.shopMoney.currencyCode | json }}
            }
        },

        &#x22;originalUnitPriceSet&#x22;: {
            &#x22;presentmentMoney&#x22; : {
                &#x22;amount&#x22;: {{ li.originalUnitPriceSet.presentmentMoney.amount | json }},
                &#x22;currencyCode&#x22;: {{ li.originalUnitPriceSet.presentmentMoney.currencyCode | json }}
            },
            &#x22;shopMoney&#x22;: {
                &#x22;amount&#x22;: {{ li.originalUnitPriceSet.shopMoney.amount | json }},
                &#x22;currencyCode&#x22;: {{ li.originalUnitPriceSet.shopMoney.currencyCode | json }}
            }
        },

        &#x22;product&#x22;: {
            {% comment %}rest of Product omitted{% endcomment %}
            &#x22;title&#x22;: {{ li.product.title | json }}
        },

        &#x22;quantity&#x22;: {{ li.quantity | json }},
        &#x22;refundableQuantity&#x22;: {{ li.refundableQuantity | json }},
        &#x22;requiresShipping&#x22;: {{ li.requiresShipping | json }},
        &#x22;restockable&#x22;: {{ li.restockable | json }},

        &#x22;sellingPlan&#x22;: {
            &#x22;name&#x22;: {{ li.sellingPlan.name | json }}
        },

        &#x22;sku&#x22;: {{ li.sku | json }},

        &#x22;taxLines&#x22;: [
            {% for tl in li.taxLines %}
                {% if forloop.first != true %},{% endif %}
                {
                    &#x22;priceSet&#x22;: {
                        &#x22;presentmentMoney&#x22; : {
                            &#x22;amount&#x22;: {{ tl.priceSet.presentmentMoney.amount | json }},
                            &#x22;currencyCode&#x22;: {{ tl.priceSet.presentmentMoney.currencyCode | json }}
                        },
                        &#x22;shopMoney&#x22;: {
                            &#x22;amount&#x22;: {{ tl.priceSet.shopMoney.amount | json }},
                            &#x22;currencyCode&#x22;: {{ tl.priceSet.shopMoney.currencyCode | json }}
                        }
                    },
                    &#x22;rate&#x22;: {{ tl.rate | json }},
                    &#x22;ratePercentage&#x22;: {{ tl.ratePercentage | json }},
                    &#x22;title&#x22;: {{ tl.title | json }}
                }
            {% endfor %}
        ],
        &#x22;taxable&#x22;:{{ li.taxable | json }},
        &#x22;title&#x22;:{{ li.title | json }},

        &#x22;totalDiscountSet&#x22;: {
            &#x22;presentmentMoney&#x22; : {
                &#x22;amount&#x22;: {{ li.totalDiscountSet.presentmentMoney.amount | json }},
                &#x22;currencyCode&#x22;: {{ li.totalDiscountSet.presentmentMoney.currencyCode | json }}
            },
            &#x22;shopMoney&#x22;: {
                &#x22;amount&#x22;: {{ li.totalDiscountSet.shopMoney.amount | json }},
                &#x22;currencyCode&#x22;: {{ li.totalDiscountSet.shopMoney.currencyCode | json }}
            }
        },

        &#x22;unfulfilledDiscountedTotalSet&#x22;: {
            &#x22;presentmentMoney&#x22; : {
                &#x22;amount&#x22;: {{ li.unfulfilledDiscountedTotalSet.presentmentMoney.amount | json }},
                &#x22;currencyCode&#x22;: {{ li.unfulfilledDiscountedTotalSet.presentmentMoney.currencyCode | json }}
            },
            &#x22;shopMoney&#x22;: {
                &#x22;amount&#x22;: {{ li.unfulfilledDiscountedTotalSet.shopMoney.amount | json }},
                &#x22;currencyCode&#x22;: {{ li.unfulfilledDiscountedTotalSet.shopMoney.currencyCode | json }}
            }
        },

        &#x22;unfulfilledOriginalTotalSet&#x22;: {
            &#x22;presentmentMoney&#x22; : {
                &#x22;amount&#x22;: {{ li.unfulfilledOriginalTotalSet.presentmentMoney.amount | json }},
                &#x22;currencyCode&#x22;: {{ li.unfulfilledOriginalTotalSet.presentmentMoney.currencyCode | json }}
            },
            &#x22;shopMoney&#x22;: {
                &#x22;amount&#x22;: {{ li.unfulfilledOriginalTotalSet.shopMoney.amount | json }},
                &#x22;currencyCode&#x22;: {{ li.unfulfilledOriginalTotalSet.shopMoney.currencyCode | json }}
            }
        },

        &#x22;unfulfilledQuantity&#x22;: {{ li.unfulfilledQuantity | json }},

        &#x22;variant&#x22;: {
            {% comment %}rest of variant omitted {% endcomment %}
            &#x22;title&#x22;: {{ li.variant.title | json }}
        },

        &#x22;variantTitle&#x22;: {{ li.variantTitle | json }},
        &#x22;vendor&#x22;: {{ li.vendor | json }}
    }
{% endfor %}
]

}