CMS Development

AWills_123
Member

Multiplying properties in an Email

SOLVE

Hello, I am trying to multiply two variable deal properties together for an email. Here is the code that I have made for the email thus far:

 

 

 

 

<p>
{% email_each list="deal.line_items" item="line_item" %}
<div style="display: flex; flex-direction:column; width: fit-content; margin: 45px 0">
  <span>{{line_item.name}} - {{ line_item.quantity }} - {{ line_item.price }} </span>
<div style="display: flex; flex-direction: column; height: 110px;">
  <img src='{{line_item.ip__ecomm_bridge__product_image}}' style="max-width: 100%; max-height" />
  </div>
</div>
{% endemail_each %}
 </p>

 

 

 

 


This is meant to display items a customer purchases in a follow-up email.

I want to multiply the item quantity by the item price so that I can show how much 'x' number of items costs.

Is there any way to do this?

0 Upvotes
1 Accepted solution
Markestac
Solution
Participant | Gold Partner
Participant | Gold Partner

Multiplying properties in an Email

SOLVE

Hi @AWills_123   

To calculate the total amount for a line item in HubSpot emails, you don't need to manually multiply the quantity by the price. Instead, you can simply use the following personalization token:
{{ line_item.amount }}

This token automatically calculates the total amount for the product based on the quantity and the price. HubSpot will handle the calculation for you, so you don't have to worry about writing any custom code. Just use {{ line_item.amount }} wherever you need to display the total amount for a product in your email.

I already created an email module like this:

{% email_each list="deal.line_items" item="line_item" %}
<table class="templateColumnWrapper" cellpadding="10" style="margin-top: 20px;">
  <tbody>
    <tr style="vertical-align: middle;">
      <td class="column" valign="middle">
        <img src="{{ line_item.hs_images }}" width="130" style="max-width: 130px;">
      </td>
      <td class="column summary" valign="middle" style="font-color: #000;">
        {{ personalization_token('line_item.name') }} ... <small>x</small> {{personalization_token('line_item.quantity')}}
        {{ personalization_token('line_item.price') }} = {{ personalization_token('line_item.amount') }}
      </td>
    </tr>
  </tbody>
</table>

Did my post help answer your query? Help the community by marking it as a solution

Talk to Our HubSpot Expert

Marketing Automation Agency | RevOps & CRM Consultant

Did my post help answer your query? Help the community by marking it as a solution.

View solution in original post

0 Upvotes
2 Replies 2
Markestac
Solution
Participant | Gold Partner
Participant | Gold Partner

Multiplying properties in an Email

SOLVE

Hi @AWills_123   

To calculate the total amount for a line item in HubSpot emails, you don't need to manually multiply the quantity by the price. Instead, you can simply use the following personalization token:
{{ line_item.amount }}

This token automatically calculates the total amount for the product based on the quantity and the price. HubSpot will handle the calculation for you, so you don't have to worry about writing any custom code. Just use {{ line_item.amount }} wherever you need to display the total amount for a product in your email.

I already created an email module like this:

{% email_each list="deal.line_items" item="line_item" %}
<table class="templateColumnWrapper" cellpadding="10" style="margin-top: 20px;">
  <tbody>
    <tr style="vertical-align: middle;">
      <td class="column" valign="middle">
        <img src="{{ line_item.hs_images }}" width="130" style="max-width: 130px;">
      </td>
      <td class="column summary" valign="middle" style="font-color: #000;">
        {{ personalization_token('line_item.name') }} ... <small>x</small> {{personalization_token('line_item.quantity')}}
        {{ personalization_token('line_item.price') }} = {{ personalization_token('line_item.amount') }}
      </td>
    </tr>
  </tbody>
</table>

Did my post help answer your query? Help the community by marking it as a solution

Talk to Our HubSpot Expert

Marketing Automation Agency | RevOps & CRM Consultant

Did my post help answer your query? Help the community by marking it as a solution.

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

Multiplying properties in an Email

SOLVE

Hey, @AWills_123 👋 Thanks for your question. Looking at the HubL docs, there are two ways you can implement multiplication:

Here's one example 

{{ line.item.quantity|multiply(line_item.price)|format(`currency`) }}

 

I hope this helps get you moving forward! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes