Quick question re: order.created_at

rioht
Shopify Partner
4 0 0

Hiya,

Quick question.  I'm testing a little bit of liquid code in some Shopify email notifications.  When I send test emails, order.created_at resolves to blank (or null) value in the field

I've tried processed_at, created_at, order.created_at, and they all come out to blank.  Any ideas?

Example:

    Order Number:  {{ order.order_number }}
    Order Reference Number:  {{ order.name }}
    Order Date:  {{ processed_at | datetime: "%m/%d/%y" }}
    Date Shipped:  {{ fulfillment_status | capitalize }}
    Tracking Number:  {{ fulfillment.tracking_numbers | link_to: fulfillment.tracking_urls | replace: '"', '' | replace: '[', '' | replace: ']', '' }}

0 Likes
Leon
Shopify Staff
Shopify Staff
205 1 60

Hello.

Leon here from Shopify Support.

The variable for order creation is created_at which you can then format using the date filter. 

A full reference sheet for the use of liquid in notification emails can be found on this page. 

Cheers,

Leon

0 Likes
rioht
Shopify Partner
4 0 0

Hi Leon,

Think you might've missed the part where I've already tried:

processed_at
created_at
order.created_at

-- thoughts?

0 Likes
Leon
Shopify Staff
Shopify Staff
205 1 60

Were you trying to view the results in the preview or test email? As long as you're using created_at  in your template, it will show up when an email is sent to a customer for an order, but not in the preview. 

In your example: 

    Order Number:  {{ order.order_number }}
    Order Reference Number:  {{ order.name }}
    Order Date:  {{ created_at | datetime: "%m/%d/%y" }}
    Date Shipped:  {{ fulfillment_status | capitalize }}
    Tracking Number:  {{ fulfillment.tracking_numbers | link_to: fulfillment.tracking_urls | replace: '"', '' | replace: '[', '' | replace: ']', '' }}

Will show the Order date like this: 

That is what shows up when I test that code in my test-store. 

If you aren't seeing the results you'd like in a preview, a test order should result in the appearance you're going for. If it still isn't working out in an order email, please let me know. 

Leon 

0 Likes
rioht
Shopify Partner
4 0 0

Yep -- that's exactly what I was asking about.  It's not working in a notification email template I'm coding for a client.

So it should work though under normal production circumstances?
 

0 Likes
Leon
Shopify Staff
Shopify Staff
205 1 60

Yep, that's correct. Just to be 100% sure I tested {{ created_at | datetime: "%m/%d/%y" }} in my test store and the email displayed this: 

As long as you're using created_at as formatted in the example in my previous post, you won't see any errors. 

0 Likes
rioht
Shopify Partner
4 0 0

grazie -- thanks leon!

0 Likes
Schlingsi
New Member
4 0 0

{{ created_at | datetime: "%m/%d/%y" }} does not work in any email notifications. Comes out blank. 

datetime doesn't seem to exist anymore either.

The correct filter is supposed to be "date" according to your documentation: https://help.shopify.com/themes/liquid/filters/additional-filters#date

{{ created_at | date: "%d %m %y" }} 

Does not work either. 

Please advise

 

0 Likes
aramael
New Member
2 0 0

Is there a reason that some of the Notification email variables that are included in production are not actually set up in the preview editor?

Is there a documented list of variables that are excluded from the preview to make sure that I'm properly using the tools correctly? I've spent a little while trying to understand what might be happening just to discover its apparently an inaccurate preview instead of bad liquid programming. 

0 Likes