Shrujal Patel
Shrujal Patel

Reputation: 1

How can I access note_attributes of order.json inside Shopify notification email template

I want to edit the Shopify notification email template - the one when customer place the order. In Email template I want to display the value of Order Due Date & Order Due Time. These values are available inside the note_attributes of order.json.

"note_attributes": [
            {
                "name": "Order Fulfillment Type",
                "value": "Local Delivery"
            },
            {
                "name": "Slot First Loaded TimeStamp",
                "value": "1729504319086"
            },
            {
                "name": "Order Due Date",
                "value": "Tue, 22 Oct 2024"
            },
            {
                "name": "Order Due Time",
                "value": "9:00 AM - 12:00 PM"
            },
            {
                "name": "Translated Order Due Date",
                "value": "Tue, 22 Oct 2024"
            },
            {
                "name": "Translated Order Due Time",
                "value": "9:00 AM - 12:00 PM"
            }
        ],

Here is my code snippet for Order Confirmation Email Template:

{% case delivery_method %}
    {% when 'pick-up' %}
        You’ll receive an email when your order is ready for pickup.
    {% when 'local' %}
        {% assign pickup_date = "" %}
        {% assign pickup_slot = "" %}

        {% for attribute in note_attributes %}
            {% if attribute.name == 'Order Due Date' %}
                {%- assign pickup_date = attribute.value -%}
            {% endif %}
            {% if attribute.name == 'Order Due Time' %}
                {%- assign pickup_slot = attribute.value -%}
            {% endif %}
        {% endfor %}


        {%- assign max_turn_around_time = line_items[0].product.metafields.custom.turn_around_time | split: " " | first -%}

        {% for line in line_items %}
            {%- assign tat = line.product.metafields.custom.turn_around_time | split: " " | first -%}
            {% if tat > max_turn_around_time %}
                {%- assign max_turn_around_time = tat -%}
            {% endif %}
        {% endfor %}

        Hi {{ customer.first_name }}, We will be picking up your items for the services listed in Order Summary below on {{ pickup_date }}, {{ pickup_slot }}.
        Your delivery will be completed within {{ max_turn_around_time }} working days.
    {% else %}
        We're getting your order ready to be shipped. We will notify you when it has been sent.
{% endcase %}

I have tried with {% for attribute in order.note_attributes %} and {% for attribute in checkout.note_attributes %}, but I'm not getting anything.

How can I display the value of Order Due Date & Order Due Time? Can we access order object in the email template?

Upvotes: 0

Views: 88

Answers (0)

Related Questions