Functions exposed by App embed
When Collection Pricing is enabled on your store, Dollarlabs exposes a set of helper functions on the global window object.
These functions let developers query pricing logic programmatically and build fully custom pricing, upsell, and UI experiences.
All APIs are read-only helpers and reflect the exact pricing rules configured inside the app.
Availability & Requirements
These functions are available only when:
Collection Pricing is enabled
The app embed is active on the theme
The page has finished loading (safe to call after
DOMContentLoaded)
1. DollarlabsGetBestPrice(variantId, quantity)
DollarlabsGetBestPrice(variantId, quantity)Returns the best applicable price for a given variant and quantity based on all active rules (customer tags, tiers, defaults, etc).
Signature
DollarlabsGetBestPrice("45132559613996", 55)Parameters
variantId
string
Shopify Variant ID
quantity
number
Quantity being evaluated
Use cases
Custom product price displays
Cart or PDP price recalculation
Showing discounted prices outside native UI
Response
Field breakdown
hasDiscount
Whether a discount applies
formattedPrice
Price formatted using store currency
priceInCents
Final unit price in cents
originalPrice
Original unit price in cents
savingsPercentage
Discount percentage applied
2. DollarlabsGetNextTierWarning(variantId, quantity)
DollarlabsGetNextTierWarning(variantId, quantity)Returns information about the next pricing tier, if one exists.
If no higher tier is configured, this function returns null.
This is especially useful for cart upsells and quantity nudges.
Signature
Use cases
“Add X more items to save more” messages
Dynamic cart banners
Quantity-based upsell prompts
Response
Field breakdown
itemsNeeded
Units required to reach the next tier
nextTierQuantity
Quantity threshold for the next tier
nextTierPrice
Unit price at the next tier
currentTierPrice
Current unit price
savingsPerUnit
Savings per item at the next tier
tag
Customer tag applied
discountMode
Pricing mode used (specific_price, %, etc)
3. DollarlabsGetPricingString(variantId)
DollarlabsGetPricingString(variantId)Returns the raw pricing configuration (from the uploaded CSV) that applies to the variant.
This is useful when you want full control over how pricing tiers are displayed or need to plug the data into custom logic.
Signature
Use cases
Custom pricing tables
Tooltips or expandable tier breakdowns
Advanced B2B pricing UI
Response
Notes
pricingStringis returned as-is from the CSVYou are free to parse and render this however you want
Multiple pricing rules may be returned if applicable
Error Handling & Defaults
If no pricing applies, functions return either:
hasDiscount: false, ornull(for next tier lookups)
Functions never mutate cart or prices — they are pure helpers
Best Practices
Cache results where possible to avoid repeated calls
Call these functions after customer context is available
Use
DollarlabsGetNextTierWarningfor upsells instead of manually recalculating tiers
If you’re building advanced B2B pricing experiences, these APIs give you full access to Dollarlabs’ pricing brain — without needing to re-implement any logic yourself.
Last updated