Using liquid code for variable content
What is liquid code?
Liquid is a flexible, open-source template language created by Shopify. It's used to dynamically display content in your Shopify store and apps like ReturnZap.
Liquid works by using placeholders (called tags and variables) to insert dynamic values, such as customer names or order details, into templates.
In ReturnZap, Liquid allows you to customize messaging like emails or return instructions based on specific customer or order data.
Use cases
Liquid code in ReturnZap can be used either to:
- Insert dynamic variables for any field from a return or a return item
- Add conditional logic to display specific blocks of text only when certain conditions are met
This code can be used in any ReturnZap email notifications, or in the in portal confirmation message. Both of these can be accessed in ReturnZap Settings > Notifications.
By using liquid code within ReturnZap notifications and messages, you can:
- Display different return instructions on the Return Confirmation Page depending on whether the customer received a prepaid label or has to arrange their own shipping
- Display different return instructions in your return confirmation emails for customers in different countries
- Provide different expected timelines and next steps on your Return Confirmation Page depending on whether the return was for refund, store credit, or for exchange
What data is available
Liquid variables in ReturnZap can reference any item or object from the return, following the structure of the example below.
"return": { "created_at": "2024-10-03T13:38:32.222378+00:00", "customer_address": { "city": "Chicago", "country": "US", "state": "IL", "street1": "Wrigley Field", "street2": "", "zip": "60613" }, "customer_email": "test@example.com", "customer_first_name": "ReturnZap", "customer_last_name": "Customer", "id": "3063978", "is_archived": false, "items": [ { "comment": "", "exchange_item": null, "id": "4601111", "image_url": "https://link-to-shopify-image", "presentment_currency": "USD", "presentment_discounted_amount": "14.990", "quantity": 1, "return_reason": "Other", "return_type": "CREDIT", "sku": "TOY431", "title": "Activity Auto", "title_clean": "Activity Auto", "value": 14.99, "vendor": "" }, { "comment": "", "exchange_item": null, "id": "4601109", "image_url": "https://link-to-shopify-image", "presentment_currency": "USD", "presentment_discounted_amount": "11.250", "quantity": 1, "return_reason": "Changed My Mind", "return_type": "REFUND", "sku": "TOY97", "title": "Animal Zone Foam T-Rex - Black", "title_clean": "Animal Zone Foam T-Rex", "value": 11.25, "vendor": "" }, { "comment": "", "exchange_item": { "exchange_variant_id": "45262228324603", "image_url": "https://link-to-shopify-image", "sku": "GREEN-SHIRT" }, "id": "4601110", "image_url": "https://link-to-shopify-image", "presentment_currency": "USD", "presentment_discounted_amount": "30.000", "quantity": 1, "return_reason": "Other", "return_type": "EXCHANGE", "sku": "BLACK-SHIRT", "title": "The Basic T-Shirt - Black", "title_clean": "The Basic T-Shirt", "value": 30, "vendor": "" } ], "rma_form_url": "https://link-to-returnzap-rma-form.pdf", "rma_number": "1.1760", "shipment": { "tracking_url": "" }, "shipping_method": "self", "shopify_order_id": "5837326942459", "shopify_order_number": "1760", "stage_id": "313387", "stage_label": "Test Stage 123", "system_stage": null, "tracking_number": "" }
Examples
Conditional Content Based on Customer Country
{% if customer.country == "GB" %} UK specific return instructions. {% else %} Return instructions for everyone else {% endif %}
Conditional Content Based on Return Shipping Method
{% if return.shipping_method == "self" %} You’ve selected to ship the item back on your own. Please be sure to include your RMA number on the outside of the shipping box. {% else %} A prepaid return label has been generated. Be sure to drop off the package within 7 days. {% endif %}
Note: Return shipping methods in ReturnZap take the format of either "self", "paid", or "free".
Display Content if Any Line Item is an Exchange
{% assign has_exchange = false %} {% for item in return.items %} {% if item.return_type == "EXCHANGE" %} {% assign has_exchange = true %} {% endif %} {% endfor %} {% if has_exchange %} We’ll ship the replacements as soon as the return is received and approved. {% endif %}