Solved

Link back to specific product page in confirmation email

sayprojects
Shopify Partner
8 0 2

Hi there,

I'd like to modify the confirmation email to include a link back to the specific product ordered by the customer.

So for example, I could say in the email: "View the product here" and then there would be a link back to the product.

This needs to be dynamic, to update the URL based on the product the customer ordered.

Any ideas? Thanks.

Accepted Solution (1)

Jason_Roberts
Explorer
64 1 51

This is an accepted solution.

Hi,

Assuming your confirmation message is the same as mine, the line item for the product itself is in a variable called line_title. You want to wrap that in an <a href> tag. The hard part was figuring out what the liquid objects are, because they're not documented. What worked for me was {{ line.url }}. That gives you the relative link to the variant that the customer purchased. Since it's a relative link, you need to add your website. You can use {{ shop.url }}{{ line.url }} just like that, no space between them.

Good luck. If you need more detailed instructions, just ask.

-J.

 

 

View solution in original post

Replies 6 (6)

Jason_Roberts
Explorer
64 1 51

This is an accepted solution.

Hi,

Assuming your confirmation message is the same as mine, the line item for the product itself is in a variable called line_title. You want to wrap that in an <a href> tag. The hard part was figuring out what the liquid objects are, because they're not documented. What worked for me was {{ line.url }}. That gives you the relative link to the variant that the customer purchased. Since it's a relative link, you need to add your website. You can use {{ shop.url }}{{ line.url }} just like that, no space between them.

Good luck. If you need more detailed instructions, just ask.

-J.

 

 

sayprojects
Shopify Partner
8 0 2

Hi J, thank you for the response!

Here is the email code where it mentions line_title.  What part of this would be wrapped and how so? I appreciate the help.

<table class="row">
  {% for line in subtotal_line_items %}
  <tr class="order-list__item">
    <td class="order-list__item__cell">
      <table>
        <td>
          {% if line.image %}
            <img src="{{ line | img_url: 'compact_cropped' }}" align="left" width="60" height="60" class="order-list__product-image"/>
          {% endif %}
        </td>
        <td class="order-list__product-description-cell">
          {% if line.product.title %}	
            {% assign line_title = line.product.title %}	
          {% else %}	
            {% assign line_title = line.title %}	
          {% endif %}

          {% if line.quantity < line.quantity %}
            {% capture line_display %} {{ line.quantity }} of {{ line.quantity }} {% endcapture %}
          {% else %}
            {% assign line_display = line.quantity  %}
          {% endif %}

          <span class="order-list__item-title">{{ line_title }} × {{ line_display }}</span><br/>

          {% if line.variant.title != 'Default Title' %}
            <span class="order-list__item-variant">{{ line.variant.title }}</span><br/>
          {% endif %}

          {% if line.selling_plan_allocation %}
            <span class="order-list__item-variant">{{ line.selling_plan_allocation.selling_plan.name }}</span><br/>
          {% endif %}

          {% if line.refunded_quantity > 0 %}
            <span class="order-list__item-refunded">Refunded</span>
          {% endif %}

          {% if line.discount_allocations %}
            {% for discount_allocation in line.discount_allocations %}
              {% if discount_allocation.discount_application.target_selection != 'all' %}
                <span class="order-list__item-discount-allocation">
                  <img src="{{ 'notifications/discounttag.png' | shopify_asset_url }}" width="18" height="18" class="discount-tag-icon" />
                  <span>
                    {{ discount_allocation.discount_application.title | upcase }}
                    (-{{ discount_allocation.amount | money }})
                  </span>
                </span>
              {% endif %}
            {% endfor %}
          {% endif %}
        </td>
          <td class="order-list__price-cell">
            {% if line.original_line_price != line.final_line_price %}
              <del class="order-list__item-original-price">{{ line.original_line_price | money }}</del>
            {% endif %}
            <p class="order-list__item-price">
              {% if line.final_line_price > 0 %}
                {{ line.final_line_price | money }}
              {% else %}
                Free
              {% endif %}
            </p>
          </td>
      </table>
    </td>
  </tr>{% endfor %}
</table>

 

sayprojects
Shopify Partner
8 0 2

Thanks again, J! Was able to figure it out.

For anyone else with this issue...this (this is the code from the order confirmation template):

    <span class="order-list__item-title">{{ line_title }} × {{ line_display }}</span><br/>

Should turn into this:

    <span class="order-list__item-title"><a href="{{shop.url}}{{line.url}}">{{ line_title }} × {{ line_display }}</a></span><br/>

 

Jason_Roberts
Explorer
64 1 51

You got it! Well done!

mexclusiveshop
Visitor
2 0 0

Hi Sayprojects, I would like to know where would you put that? On the Add link? or do I have to go to edit them edit to add it?

sayprojects
Shopify Partner
8 0 2

I went to Settings > Notifications > Scrolled down to the email I wanted to edit > Clicked the title > Clicked the top right button 'edit code' > then pasted the code as described above. Hope this helps!