Re: Thank you page metafield

How can I display a message on my thank you page based on metafield value?

LittlePaddocks
Excursionist
45 1 9

Hi, I am trying to display a message on my thank you page when a metafield contains a certain value. I have the following code, but it does not seem to work. 

Would anyone be able to please advise? 

 

Many thanks. 

 

{% if order.metafields.custom.select_delivery_status != blank %}
    <script>Shopify.Checkout.OrderStatus.addContentBox(
    '<b><h2><u>Order status</u><br>{% case order.metafields.custom.select_delivery_status | metafield %} {% when "been left in safe place" %}<p>Please see below for a proof of delivery photo.</p> {% when "to be redelivered" %}<p>A calling card has been left at the delivery address for the recipient to rearrange delivery.</p> {% when "been delivered to recipient" %}<p>Flowers were received at the delivery address.</p> {% else %}<p>Thank you for your order!<br>Your current order status is <b>unfulfilled</b> {% endcase %}</h2></b></u>'
)
</script>
{% endif %}
Replies 2 (2)

niraj_patel
Shopify Partner
2391 516 513

Hello @LittlePaddocks 

Try this code
{% if order.metafields.custom.select_delivery_status != blank %}
<script>
{% case order.metafields.custom.select_delivery_status %}
{% when "been left in safe place" %}
Shopify.Checkout.OrderStatus.addContentBox(
'<b><h2><u>Order status</u><br><p>Please see below for a proof of delivery photo.</p></h2></b>'
);
{% when "to be redelivered" %}
Shopify.Checkout.OrderStatus.addContentBox(
'<b><h2><u>Order status</u><br><p>A calling card has been left at the delivery address for the recipient to rearrange delivery.</p></h2></b>'
);
{% when "been delivered to recipient" %}
Shopify.Checkout.OrderStatus.addContentBox(
'<b><h2><u>Order status</u><br><p>Flowers were received at the delivery address.</p></h2></b>'
);
{% else %}
Shopify.Checkout.OrderStatus.addContentBox(
'<b><h2><u>Order status</u><br><p>Thank you for your order!<br>Your current order status is <b>unfulfilled</b></p></h2></b>'
);
{% endcase %}
</script>
{% endif %}
Was my reply helpful? Click Like to let me know!
Was your question answered? Mark it as an Accepted Solution.

Shopify Partner || Helping eCommerce Stores
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution.
- For further discussion contact: Email ID- info@techlyser.com
LittlePaddocks
Excursionist
45 1 9

Hi @niraj_patel ,

 

Thanks for the reply. I have tried adding the code but unfortunately it is still not displaying. Is there any other things i could try?

 

Thanks!