E.g
I have products with two variants
Auto and Manual
When someone purchase the Auto variant, he should receive a certificate, and when someone purchase the Manual variant they should receive another certificate.
How can I make this work?
Do I need some “if” code to place in the email?
I suppose there could be a workaround similar to this one ?!
https://community.shopify.com/post/1676933
Topic summary
Goal: Customize Shopify order confirmation emails to send different certificate content based on product variant (“Auto” vs “Manual”).
Previous working method: A Liquid loop over line_items checked if the product title contained “Auto,” then displayed the certificate accordingly. This functioned when logic was based on the product title.
Issue with variants: Attempted to switch to variant-based checks using line.variant.title, but used an incorrect loop (iterating over line.variant.title rather than line_items). A separate attempt using product.variant.name led to the email always showing the Manual variant content, indicating the condition did not access the correct object in the order confirmation template.
Guidance provided: Use Liquid conditional logic to access the product variant in the email template; identify how the variant is stored (e.g., attribute/SKU), then test with each variant. A generic code example was shared but appears mismatched to Shopify’s order confirmation data structures.
Status: Unresolved. The key need is a correct Liquid example referencing the variant within the order confirmation email, likely via the line_items collection. No final solution or action item confirmed.
Yes, you can modify the order confirmation email based on the product’s variant using an “if” statement or a similar conditional logic. Here are the general steps involved:
Identify the product variant: Determine how the product variant is stored in your system. This could be a custom field, a product attribute, or part of the product SKU.
Access the variant in your email template: In your order confirmation email template, use Liquid template language or a similar templating engine to access the product variant.
Implement conditional logic: Use an “if” statement or a similar conditional expression to check the product variant. Based on the variant, include the appropriate certificate information in the email.
Test your changes: Send a test order for each product variant to ensure that the correct certificate is included in the email.
Here’s a simplified example using Liquid template language:
{% if product.variant.name == “Auto” %}
You have purchased the Auto variant. Your certificate is attached.
{% else %}You have purchased the Manual variant. Your certificate is attached.
{% endif %}In this example, product.variant.name is assumed to be the property that stores the product variant. You can replace it with the actual property used in your system.
Remember to replace the placeholder comments with the actual code or HTML to include the certificates in the email. You may also need to adjust the conditional logic based on how product variants are stored and accessed in your specific platform or system.
By following these steps and customizing the conditional logic to your specific requirements, you can effectively modify the order confirmation email based on the product’s variant.
So, until now I was using this, depending on the product’s name and it was working
{% assign certificate = false %}
{% for line in line_items %}
{% if line.title contains “Auto” %}
{% assign certificate = true %}
{% endif %}
{% endfor %}
{% if certificate %}
Here you can see the certificate
{% endif %}
However, now, that I have to change this depending on variants I tried this one but it seems I missed something because it’s not working
{% assign certificate = false %}
{% for line in line.variant.title %}
{% if line.variant.title contains “Auto” %}
{% assign certificate = true %}
{% endif %}
{% endfor %}
{% if certificate %}
Here you can see the certificate
{% endif %}
So, I changed line.title with line.variant.title
Any idea or example I can use, using the variant name?
Tried this but it always sends the Manual variant email
{% if product.variant.name == “Auto” %}
You have purchased the Auto variant. Your certificate is attached.
{% else %}You have purchased the Manual variant. Your certificate is attached.
{% endif %}