Skip to content

Instantly share code, notes, and snippets.

View steven-miller's full-sized avatar

steven-miller

View GitHub Profile
@steven-miller
steven-miller / getOrderAddress-hubspotCCA.js
Created April 16, 2024 12:35
HubSpot Programmable Automation: Retrieve Order Address from BigCommerce based on Order ID
/*
SETUP:
This must be in an "Orders" workflow
Inputs: hs_order_name = Name
Output: shipping_street_address (String)
You will need a BigCommerce API key (stored as BIGCOMMERCE_KEY) with the ability to read orders/order addresses here: https://support.bigcommerce.com/s/article/Store-API-Accounts?language=en_US#creating
You will also need your store hash (stored as STORE_HASH secret) - directions on getting this here: https://www.atensoftware.com/p90.php?q=333
*/
const axios = require('axios');
@steven-miller
steven-miller / mock-data.html
Created October 13, 2023 21:02
HubSpot: Mock data for grouped line items module
{% set SAMPLE_TEMPLATE_DATA = {
"hubspot_base_url" : "https://api.hubapi.com",
"is_preview": "true",
"quote" : {
"hubspot_owner_id": "1",
"hs_all_owner_ids": "1",
"hs_created_by_user_id": "1",
"hs_updated_by_user_id": "1",
"hs_lastmodifieddate": "1/1/20",
"hubspot_owner_assigneddate": "1/1/20",
@steven-miller
steven-miller / module.html
Created October 13, 2023 20:58
HubSpot Quotes: default line item module with grouping by "location" property
<!-- see comments for modifications -->
{% from '../../imports/mock_data.html' import SAMPLE_TEMPLATE_DATA as mock_data %}
{% set QUOTE = template_data.quote || mock_data.quote %}
{% set CURRENCY = QUOTE.hs_currency || 'USD' %}
{% set LOCALE = QUOTE.hs_locale || 'en-US' %}
{% set LANGUAGE = QUOTE.hs_language || 'en' %}
{% set ASSOCIATED_OBJECTS = QUOTE.associated_objects %}
{% set LINE_ITEMS = ASSOCIATED_OBJECTS.line_items_by_start_date ? ASSOCIATED_OBJECTS.line_items_by_start_date.PRESENT : ASSOCIATED_OBJECTS.line_items %}
@steven-miller
steven-miller / prefill-content-hubl-hubspot.html
Created June 12, 2019 00:13
Pre-filled content options for HubSpot modules
<!--
Dropdown Option Area
- before adding a new section, you need to add a new option to the "Prebuilt Modules" field on the right side
- keep in mind that the "content" section may require HTML / styling, so it may be worth tinkering with in the module tester on "custom" setting before adding new options to the dropdown
-->
{% if module.prebuilt_modules == "option_a" %}
{% set custom_values = {
'title': 'Title A',
'button_image': {
@steven-miller
steven-miller / gmail-promo-tab-module.html
Created June 11, 2019 23:40
Gmail Promotions markup in a customizable HubSpot module
<div itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="{{ module.organization_name }}" />
<meta itemprop="logo" content="{{ module.small_logo }}" />
</div>
<div itemscope itemtype="http://schema.org/DiscountOffer">
<meta itemprop="description" content="{{ module.discount_amount }}" />
<meta itemprop="discountCode" content="{{ module.discount_code }}" />
<meta itemprop="availabilityStarts" content="{{ module.deal_starts|datetimeformat('%Y-%m-%dT%H:%M:%S%z') }}" />
<meta itemprop="availabilityEnds" content="{{ module.deal_ends|datetimeformat('%Y-%m-%dT%H:%M:%S%z') }}" />
</div>
@steven-miller
steven-miller / price-estimator.html
Created June 10, 2019 01:50
HubSpot customized form for price estimates
<p>Answer the questions below to get a good idea of the cost to clean your house each month in the Boston area (disclaimer below)</p>
<script>
/*
List of elements
options for those elements:
what_size_is_your_home_
0 = Studio
1 = 1 Bedroom
2 = 2 Bedroom
@steven-miller
steven-miller / podcast-based-hubspot-blog.html
Created June 10, 2019 01:15
Script that calls HubDB and appends podcast information to HubSpot blog posts
<!-- note: json is unminified for readability -->
<!-- I'm using this section to print out the HubDB for the podcast on the page so I can easily access it by blog ID.
I would use one table per podcast, as it seems rare you'd get much past a few hundred rows. -->
<div id="json-object" style="display:none;">
[{
{% for row in hubdb_table_rows(677960) %}
"{{ row.blog_id }}": {
"soundcloud_track_number": "{{ row.soundcloud_track_number }}",
@steven-miller
steven-miller / rotation-by-datetime.js
Created June 10, 2019 00:17
Time-based HubSpot Chatbot rotation code
exports.main = (event, callback) => {
// get current time in unix
const now = new Date();
const hourOfDayInUTC = now.getUTCHours();
const day = now.getDay(); // use this to check whether it's the weekend
// prep response object
const responseJson = {
responseExpected: false
}
@steven-miller
steven-miller / pageview-tracker-over-time.html
Last active June 9, 2019 17:40
Time-based page view tracker in HubSpot - can be added as a custom module and then can filter on custom events
<script>
$(document).ready(function() {
// verbose: get current unix datetime - outputs in MS
var dateNow = Date.now();
// if the "cookie" already exists
if (localStorage.getItem('viewCounter') !== null) {
// shorthand for viewCounter
var viewCounter = JSON.parse(localStorage.getItem('viewCounter'));
@steven-miller
steven-miller / getbooks.txt
Last active March 27, 2019 03:50
Get all books
/books/:id
Method Details
HTTP Methods: GET
Response Format: json
Example GET URL:
api.example.com/books/6
Example response (data is filler, reflective of type only):