Customized Pre-Order Notification using Tags and Liquid Variables

Highlighted
New Member
3 0 0

Hey Guys,

we started using Pre-Order Manager as a tool to accept pre-orders. The app works great but still lacks the feature of sending automated mails to customers that did a pre-order.

That means customers currently receive the same order notification for 'normal'-orders and 'pre'-orders. 

I actually like the overall style of the email template provided as default by shopify so i tryed to figure out a way using the Tag-feature and liquid variables in the mail.

(NOTE: we automatically tag pre-ordered products with "pre-ordered" using Pre-Order Manager)

This is how it looks like:

 

{% if order.tag ==  pre-order %} {% capture email_title %}Pre-order Title{% endcapture %} {% capture email_body %}Pre-order Body{% endcapture %}

{% else %}  {% capture email_title %}Normal Order Title {% endcapture %} {% capture email_body %}Normal Order Body{% endcapture %} {% endif %}

 

Apparently i am missing something since it's allways showing the Pre-Order Message.

I tryed opening the statement with: {% for tag in order.tags %} and end it with {% endfor %} but it doesn't work either.

Anybody here seeing the error in my coding?

Thanks for your help!

 

0 Likes
Highlighted
Shopify Partner
385 0 57

Hello,

You doing a couple of things wrong.

You compairing a variable false with a variable false therefore it would always be false, hence the result you are having. Tags would always be strings and therefore need to be compaired with "". Also tags could consist of multiple tags therefore you need to use contains as it would return a "tag, tag1, tag2".

{% if tags contains 'pre-ordered' %}
  Pre order
{% else %}
  Not a preorder
{% endif %}

Kasimir

"Good design is good business"
0 Likes
Highlighted
New Member
3 0 0

Hey Kasimir,

thanks for the fast response. Your code did exactly what he should do.

However i found out that it is not solving the problem since Pre-Order Manager assigns the tags with a delay. That means when the confirmation is beeing send, the order is might not yet tagged as 'pre-order' hence the 'normal' confirmation is beeing send.

I thought it would be better to use another variable: variant.inventory_quantity

That's what i tried without success:

 

{% if variant.inventory_quantity < 0 %}

Pre order

{% else %} Not a preorder

{% endif %}

 

Sorry for poor liquid coding skills...

Any ideas? Thank you for your help :)

 

 

0 Likes
Highlighted
Shopify Partner
385 0 57

Hello Berenisce,

That would be available on the item variant.

Lets assume we ignore the fact that people could pre order items and still have items that are not preordered. Not ideal if this is not the case, then you would need to reconsider the email being send to display if the actual ITEM is a preorder or not.

So if we assume that all items are preorder items if one of the items is preordered we can do something like.

On the very top of the notification we need to find out if there are any items in the line items ordered that have their inventory lower than 0. To do this we loop thro the list of ordered items:

{% assign preorder = false %}
{% for line in line_items %}
  {% if line.variant.inventory_quantity < 0 %}
    {% assign preorder = true %}
    {% break %}
  {% endif %}
{% endfor %}

Then you can use that to trigger the same code that you were previously using:

{% if preorder %}
  Preorder
{% else %}
  Not a preorder
{% endif %}

Still would not say its an ideal solution for your problem.

Kasimir

"Good design is good business"
0 Likes
Highlighted
New Member
3 0 0

Hey Kasimir,

thank you so much for your help. I implemented your code suggestion and it works perfect.

However you are right, it might not be ideal solution because of the fact that the customer might order a pre-ordered product and one that is still in-stock since this would trigger the pre-order message.

But for a business at our scale this should work just fine if you add some explanatory text into the message :D

Again, thank you so much for taking the time.

0 Likes
Highlighted
Tourist
3 0 2

Hello Kasimir,

 

What would the solution be if I NEEDED to display either 'pre-ordered' OR 'In Stock' on each line item individually within the order confirmation email?

 

You said previously: Lets assume we ignore the fact that people could pre order items and still have items that are not preordered. Not ideal if this is not the case, then you would need to reconsider the email being send to display if the actual ITEM is a preorder or not. 

 

If we did not ignore the fact people could have pre-order items AND non pre order items - How would we code this?

 

Note: I am also using the 'Pre-Order Manager' therefore cannot try to capture the order 'Tag' as there is a delay. 

Thanks

Dan

0 Likes
Highlighted
Tourist
3 0 2

Hi,

 

So I found a solution for this on my order confirmation email.

 

{% if line.variant.inventory_quantity >= 1 %}
In Stock
{% else %}
Pre-Ordered
{% endif %}

 

Capture-preorder.PNG

 

Hope this helps. 

 

Thanks

Dan

 

1 Like
Highlighted
Tourist
4 0 0

Hi guys,  @danieldowney68 's solution works, thank you, Daniel. 

Is it possible to show this message in Email template too?
Because we're writing the arrival dates there. 
Screenshot: https://prnt.sc/sh2z6l


Thanks guys,
Shinee

0 Likes
Highlighted
Tourist
3 0 2

Hi @Shinee I'm glad this worked for you! 

You can have the message show by inserting it beside the 'Pre-Order' output.  (See below)

 

{% if line.variant.inventory_quantity >= 1 %}
In Stock
{% else %}
Pre-Ordered - We will fulfill the order as soon as the item becomes available 
{% endif %}

 I hope this helps. 

 

Thanks

Daniel

1 Like
Highlighted
New Member
2 0 0

I have the same issue. Where abouts in the order confirmation would this need to be placed?

 

0 Likes