Last active
December 19, 2024 18:07
-
-
Save NickDeckerDevs/ce4896cce76fb9e9d473083d68491481 to your computer and use it in GitHub Desktop.
hubspot - crm objects getting products and converting dates to compare for anything updated from midnight until now
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% set products = crm_objects("product", "limit=100") %} | |
{% set midnight_today = local_dt|format_date('M/d/yy')|strtodate('M/d/yy')|unixtimestamp %} | |
{% if products_data.total > 0 %} | |
<div class="products__wrapper"> | |
{% for result in products.results %} | |
{% set product = crm_object("product", result.id, "name,price,hs_lastmodifieddate,createdate") %} | |
{% set updated_date = product_details.hs_lastmodifieddate|strtodate('M/d/yy')|unixtimestamp %} | |
{% set created_date = product_details.createdate|strtodate('M/d/yy')|unixtimestamp %} | |
{% if(created_date >= midnight_today || updated_date >= midnight_today) %} | |
<div class="product__card"> | |
<h3>{{ product.name }}</h3> | |
<div class="product__price">{{ product.price|format_currency_value(locale='en-US', currency='USD', maxDecimalDigits=2, minDecimalDigits=0) }}</div> | |
</div> | |
{% endif %} | |
{% endfor %} | |
</div> | |
{% else %} | |
<p class="error">There were no products updated today</p> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment