Accessing collections in notification emails

Highlighted
Shopify Partner
1 0 1

I'm trying to add recommended products to the order confirmation notification email (without adding yet another app). I've made a collection called 'Recommended Projects' and have added a few products to it. Then just to test out if collections with products is even recognized properly, I added this code to my order confirmation notification:

{% assign collection = collections['recommended-products'] %}

{% assign recommendations = false %}
{% if collection and collection.all_products_count > 0 %}
  {% assign recommendations = true %}
{% endif %}

{% if recommendations %}
  Here are some products you may like.
{% else %}
  No recommendations for you.
{% endif %}

It's just returning 'No recommendations for you.' Any clue what's going on? I know this would work on a regular shopify page. Are collections even accessible inside notifications?

 

Highlighted
New Member
1 0 0

Anybody know if you're able to get collections data inside shopify email notifications via liquid tags?

I know this stuff works inside shopify templates, and a lot of those tags/variables work inside notifications, but I just can't seem to access any category products though. Any thoughts?

0 Likes
Highlighted

Hi Luke,

I've looked into this exact same thing for one of my apps (OrderlyEmails - Email Notification Themes for Shopify), and there is no way to access the Collection (or products not in the order itself) from within an email template. A lot of apps do "recommended products" in emails, but they all send the email themselves, instead of using the default Shopify email system.. so that's how they get around it.

The way I solved this was to synchronize the Collection to a Metafield on the Shop with the info needed in the recommendation, as you do have access to Metafields in the email templates. But you would need some software which will do the syncronization (Collection -> Metafield) for you on a regular basis, to make sure they continue to contain the correct info.

I know it's not what you want to hear, but my app can solve this for you AND you can edit the collection it creates for you to make the product recommendations in line with what you want. The email themes in the app are a one time purchase, so there is no ongoing cost for it.. and we'll continue synchronizing your collection to the metafield every 4 hours ;)

https://apps.shopify.com/email-templates

Hope it helps.

Bjorn

Bjorn Forsberg
Chief Eternal Optimist
FORSBERGtwo / Apps for Shopify

Bjorn Forsberg | FORSBERG+two | Award-winning Shopify Apps since 2011
Highlighted
Tourist
4 0 0

4 years later is this possible to do yet with just liquid code?

0 Likes