Add stamp to custom theme

Hi,
I am trying to add a stamp to a purchase order custom theme. Basically I want to keep the purchase order on my records even though it hasn’t progressed to a Purchase Invoice. This was cancelled due to parts ETA was 6 months. I’ve added two custom fields, “Status” and “Date” and added the below to my theme to successfully show “CANCELLED” boxed, but been unable to have the stamp to show “CANCELLED - 10/09/2021” boxed.

image

Can someone help edit the below to have the date included in the stamp? Thank you

    {% for field in custom_fields %}
    <tr>
        <td colspan="99">
            {% if field.text == 'PROCESSED' %}
            <div style="text-align: center; margin-top: 40px"><span style="color: #006400; border-width: 5px; border-color: #006400; padding: 10px; font-size: 20px">{{ field.text }}</div>
            {% endif %}
            
            {% if field.text == 'CANCELLED' %}
            <div style="text-align: center; margin-top: 40px"><span style="color: #FF0000; border-width: 5px; border-color: #FF0000; padding: 10px; font-size: 20px">{{ field.text }}</div>
            {% endif %}                
        </td>
    </tr>
    {% endfor %}

there seems to be no code written to loop through your Date custom field.

You can try this

{% for field in custom_fields %}
    {% if field.label == "status" %}{% capture status %}{{ field.text }}{% endcapture %}{% assign status = status %}{% endif %}
    {% if field.label == "canceldate" %}{% capture canceldate %}{{ field.text }}{% endcapture %}{% assign canceldate = canceldate %}{% endif %}
{% endfor %}

{% for field in custom_fields %}
            <tr>
                <td colspan="99">
                    {% if field.text == 'PROCESSED' %}
                    <div style="text-align: center; margin-top: 40px"><span style="color: #006400; border-width: 5px; border-color: #006400; padding: 10px; font-size: 20px">{{ field.text }} - {{ canceldate }}</div>
                    {% endif %}
                    
                    {% if field.text == 'CANCELLED' %}
                    <div style="text-align: center; margin-top: 40px"><span style="color: #FF0000; border-width: 5px; border-color: #FF0000; padding: 10px; font-size: 20px">{{ field.text }} - {{ canceldate }}</div>
                    {% endif %}                
                </td>
            </tr>
        {% endfor %}
1 Like

That’s the bit I am struggling with. I’m a novice in this :slightly_smiling_face:. Can you help modifying the code?
Thanks

rather than creating two separate fields for Status and Date, it would be simpler to create two Date type custom fields with labels CANCELLED - and PROCESSED - like below example.

then if you do not have any other custom fields, you can use the code below.

{% for field in custom_fields %}
        <tr>
            <td colspan="99">
                <div style="text-align: center; margin-top: 40px"><span style="color: #FF0000; border-width: 5px; border-color: #FF0000; padding: 10px; font-size: 20px">{{ field.label }} {{ field.text }}</div>
            </td>
        </tr>
{% endfor %}
2 Likes

Interesting sharpdrivetek. I will try it as you suggested.
Thanks for the suggestion

Hi Sharpdrivetek.

I tested it and unfortunately doesn’t provide the desired output. for both PROCESSED and CANCELLED labels are red. Ideally CANCELLED be in red and PROCESSED in green.

You can try this:

{% for field in custom_fields %}
        <tr>
            <td colspan="99">
                 {% if field.label == 'PROCESSED' %}
                    <div style="text-align: center; margin-top: 40px"><span style="color: #006400; border-width: 5px; border-color: #006400; padding: 10px; font-size: 20px">{{ field.label }} {{ field.text }}</div>
                    {% endif %}
                    
                    {% if field.label == 'CANCELLED' %}
                    <div style="text-align: center; margin-top: 40px"><span style="color: #FF0000; border-width: 5px; border-color: #FF0000; padding: 10px; font-size: 20px">{{ field.label }} {{ field.text }}</div>
                    {% endif %}             
            </td>
        </tr>
{% endfor %}

I’ll give it a go. Thanks Frankie

I changed the code a little so the other custom-fields are also vissible.

        {% for field in custom_fields %}
        <tr>
            <td colspan="99">
                {% if field.label == 'PROCESSED' %}
                    <div style="text-align: center; margin-top: 40px"><span style="color: #006400; border-width: 5px; border-color: #006400; padding: 10px; font-size: 20px">{{ field.label }} {{ field.text }}</div>
                {% elsif field.label == 'CANCELLED' %}
                    <div style="text-align: center; margin-top: 40px"><span style="color: #FF0000; border-width: 5px; border-color: #FF0000; padding: 10px; font-size: 20px">{{ field.label }} {{ field.text }}</div>
                {% else %}
                    <div style="font-weight: bold; padding-top: 20px">{{ field.label }}</div>
                    <div>{{ field.text | newline_to_br }}</div>
                {% endif %}
            </td>
        </tr>
        {% endfor %}
2 Likes

:+1:. Much appreciated

Hi Frankie
It works a treat. Thanks