CMS Development

SFurlong
Contributor | Diamond Partner
Contributor | Diamond Partner

Pulling in Deal Line items for automated emails

SOLVE

Hi,

 

I currently have an email set up that pulls in a deal URL from an abandoned cart. 

 

I simply have a button set up like this:

{{deal.url}}/{{deal.order_id}}

 

This is working great.

 

However, I now need to pull in line item details to display to the user. I've created a cusom module and added similar code I found on this discussion thread:

{% for line_item in deal.line_items %}
    {{ line_item.name }}
{% endfor %}

 

I'm not seeing any errors but nothing is returned. However I'm we're also using the "send preview" feature since the site is live. 

 

A few questions:

  • Is pulling the line items from a deal like this possible?
  • If so, am I approaching it the correct way here?
  • Since it's an automated live email, could this be working but I need a live test to confirm?

Thank you!

Stu

1 Accepted solution
himanshurauthan
Solution
Thought Leader | Elite Partner
Thought Leader | Elite Partner

Pulling in Deal Line items for automated emails

SOLVE

Hello @SFurlong 

to pull line items from a deal in a HubSpot email using the code you provided.

you can combine the deal URL and line item details in a HubSpot email:

<p>Deal URL: <a href="{{ deal.url }}/{{ deal.order_id }}">{{ deal.url }}/{{ deal.order_id }}</a></p>

<p>Line items:</p>
<ul>
{% for line_item in deal.line_items %}
    <li>{{ line_item.name }} - {{ line_item.price }}</li>
{% endfor %}
</ul>

 

the deal.url and deal.order_id variables are used to create a link to the deal page. The deal.line_items loop is used to display a list of line items, including their name and price.

If you're not seeing any errors in the email editor and the code is not displaying any output, it's possible that the deal you're testing with doesn't have any line items. You may need to create a new deal with line items to test the email.

It's also possible that the issue is related to the "send preview" feature. The preview may not show the updated email content if the email is triggered by an automation or workflow. To test the email with live data, you can create a test deal with line items and trigger the email manually.

Digital Marketing & Inbound Expert In Growth Hacking Technology

View solution in original post

5 Replies 5
GRajput
Key Advisor | Platinum Partner
Key Advisor | Platinum Partner

Pulling in Deal Line items for automated emails

SOLVE

Hi @SFurlong 

Yes, pulling line items from a deal in HubSpot is possible, and your approach looks correct. The code you have used in the custom module should iterate over the line items associated with the deal and print the name of each item.

As for why you are not seeing any output, there could be a few possible reasons. One possible issue is that there may not be any line items associated with the deal. You can check this by logging into your HubSpot account and navigating to the deal record. If there are no line items listed, then you may need to adjust your email template to handle this case.

Another possibility is that the custom module is not correctly formatted. You can try using the "Preview" feature in HubSpot to test the email and see if the line items are displayed correctly. If the preview looks good, then the issue may be with the live email sending process. In this case, you may want to test the email in a live environment to confirm that it is working as expected.

Finally, you can also try using the HubSpot developer tools to troubleshoot the issue. You can use the tools to view the data associated with the deal and make sure that the line items are being properly populated. You can also use the tools to test your code snippets and make sure that they are working correctly.

In summary, pulling line items from a deal in HubSpot is possible, and your approach looks correct. However, there may be a few possible issues that could be causing the custom module to not display any output. You can try testing your code in a preview, live environment, or using the HubSpot developer tools to troubleshoot the issue.

 

Please mark it as SOLUTION ACCEPTED if you like the solution.

Thank you!




Gaurav Rajput
Director, MarTech( Growth Natives)

Book a meeting


Matgyron
Participant

Pulling in Deal Line items for automated emails

SOLVE

Hi there,

there is any way to transalte property " line_item.name " value in different language from email cart summary? 

Goal will be have different dynamic module base on contact language.

<h2 style="margin-top: 20px;"></h2>
<div class="order-summary">
{% email_each list="deal.line_items" item="line_item" %}
<table class="templateColumnWrapper" cellpadding="10" style="margin-top: 20px;">
<tbody>
<tr>
<td class="column" style="vertical-align: middle;">
<img src="url" width="130" style="max-width: 130px;">
</td>
<td class="column summary" style="vertical-align: top;">
{{ module.order_summary }}
</td>
</tr>
</tbody>
</table>
{% endemail_each %}
</div>

0 Upvotes
himanshurauthan
Solution
Thought Leader | Elite Partner
Thought Leader | Elite Partner

Pulling in Deal Line items for automated emails

SOLVE

Hello @SFurlong 

to pull line items from a deal in a HubSpot email using the code you provided.

you can combine the deal URL and line item details in a HubSpot email:

<p>Deal URL: <a href="{{ deal.url }}/{{ deal.order_id }}">{{ deal.url }}/{{ deal.order_id }}</a></p>

<p>Line items:</p>
<ul>
{% for line_item in deal.line_items %}
    <li>{{ line_item.name }} - {{ line_item.price }}</li>
{% endfor %}
</ul>

 

the deal.url and deal.order_id variables are used to create a link to the deal page. The deal.line_items loop is used to display a list of line items, including their name and price.

If you're not seeing any errors in the email editor and the code is not displaying any output, it's possible that the deal you're testing with doesn't have any line items. You may need to create a new deal with line items to test the email.

It's also possible that the issue is related to the "send preview" feature. The preview may not show the updated email content if the email is triggered by an automation or workflow. To test the email with live data, you can create a test deal with line items and trigger the email manually.

Digital Marketing & Inbound Expert In Growth Hacking Technology
DStern
Participant

Pulling in Deal Line items for automated emails

SOLVE

Is there any chance you could create a video tutorial showing how to implement the code? I have a similar need: I want to send a confirmation email template when a deal is won, including the line items of the deal, such as the item name, price, and discount. Any assistance you can provide would be greatly appreciated.

0 Upvotes
SFurlong
Contributor | Diamond Partner
Contributor | Diamond Partner

Pulling in Deal Line items for automated emails

SOLVE

Thanks for this answer Himanshu! This confirmed for me that the code we're using is correct, since we have that exact setup in our email and module as well. We're still having issues (even on live automated emails) but I don't think it's related to the code or bad syntax at this point.

 

I'll update this when we narrow down the problem, but I'll leave this marked answered since that was exactly the confirmation I was looking for. Thanks!