Tiered Progress Bar Methods

SmartCart.addFreeProductvoid

Adds a free gift to the cart

SmartCart.addSingleVariantFreeProduct

Adds the only available variant of a free gift product to the cart (used when there is only one variant available, which is either in variant_ids, or variants array)

SmartCart.calculatePercentageWithNormalTierMinimumsnumber

Calculates the progress bar's percentage when there is no Free Shipping On Subscription option enabled / satisfied

SmartCart.calculatePercentageWithSubscriptionProductnumber

Calculates the progress bar's percentage when there is a Free Shipping On Subscription option enabled + satisfied

SmartCart.freeProductOptionsArray

Gets the options for a free gift product - either all variants or selected variants

SmartCart.freeProductPromptstring

Gets text for the Free Product button - based on the product's status

SmartCart.freeProductStylesobject | void

Gets the product's background image / styles

SmartCart.freeProductTileStyleobject | undefined

Gets the product's tile width, based on the number of earned products

SmartCart.getBarForLocationobject

Get progress bar settings based on location

SmartCart.getCurrentTierobject | null

Gets current tier

SmartCart.getEarnedProductsArray.<object>

Gets the list of earned products from the bar

SmartCart.getFreeVariantTitlestring

Gets the gift product's variant title

SmartCart.getGiftAreaTitlestring

Gets the Gift Area Title to display above the Gift Area

SmartCart.getProductsWithoutSelectionArray.<object>

Gets the earned gifts in the cart that don't have a variant selected

SmartCart.getProgressBarSettingsobject | null

Get the progress bar settings object

SmartCart.getProgressStepIconSizeobject

Utility helper for getting the style object with configured sizes

SmartCart.getSpendToNextTiernumber

Gets the difference between the subtotal and the next tier's minimum

SmartCart.getTierCompletedTextstring

Get the text for the completed tier

SmartCart.getTierFeedbackTextstring

Get the text for the current tier (either in progress or completed)

SmartCart.getTierLabelstring

Gets the step label for a given tier

SmartCart.getTierMinimumnumber | null

Gets the minimum threshold for a given tier

SmartCart.getTieredBarProductDataobject

Checks local storage for cached product data, and fetches any missing product data from the API

SmartCart.hasFreeShippingOnSubscriptionboolean

Determine if Free Shipping should be satisfied by a subscription product in the Cart

SmartCart.hasGiftSelectionboolean

Determine if the gift product requires a customer variant selection

SmartCart.hasProgressPromptboolean | string

Determine if the progress bar has a prompt for the current tier

SmartCart.hasTierProgressboolean

Determine if there is any progress to show in the progress bar

SmartCart.isGiftItemboolean

Determines whether a cart item is a free gift item from the progress bar

SmartCart.isProgressBarEnabledboolean

Determine if the progress bar is enabled

SmartCart.progressBarSubtotalnumber

Gets the current subtotal for the TPB, with some exclusion logic

SmartCart.progressStepMaxWidthstring

Utility helper for getting the max width of the tiers for CSS

SmartCart.progressTierIconstring

Utility helper for getting the icon for a given tier

SmartCart.progressTierReachedboolean

Determines if the tier has been reached based on the subtotal

SmartCart.removeAllFreeGifts

Removes all free gifts from the cart

SmartCart.removeFreeProduct

Deselects a free gift from the TPB Gift Area:

  • Updates the product status to loading
  • Removes the gift from the cart
  • Updates the product status to removed
  • Adds the gift to the declined gifts cookie
SmartCart.selectFreeProductVariant

Handles the selection of a free gift variant in the bar

SmartCart.shouldFilterOutOfStockVariantsFromTierboolean

Determines whether Out of Stock variants should be hidden from the progress bar

SmartCart.shouldRenderEarnedGiftboolean

Determines whether a gift product in the earned products array should be rendered with the bar (helpful to prevent rendering out chosen gifts with the bar while in Line Item Mode)

SmartCart.shouldRenderGiftAreaboolean

Determines whether the Gifts Area should be rendered based on the progress bar settings and earned products state

SmartCart.shouldRenderGiftAreaTitleboolean

Determine if the Gift Area Title should be used

SmartCart.tierCompleteIconstring

Utility helper for getting the icon for a given tier (Complete)

SmartCart.tierProgressIconstring

Utility helper for getting the icon for a given tier (In Progress)

SmartCart.tiersPercentageCompletestring | number

Calculates the progress bar's percentage completed

SmartCart.updateFreeProducts

Updates the free products in the cart based on the current subtotal. This contains the primary logic for the progress bar cart management

SmartCart.addFreeProductvoid

Adds a free gift to the cart

ParamTypeDescription
productobjectThe product object

SmartCart.addSingleVariantFreeProduct

Adds the only available variant of a free gift product to the cart
(used when there is only one variant available, which is either in variant_ids, or variants array)

ParamTypeDescription
productobjectThe product object

SmartCart.calculatePercentageWithNormalTierMinimumsnumber

Calculates the progress bar's percentage when there is no Free Shipping On Subscription option enabled / satisfied

Returns: number - The percentage as a number

ParamTypeDescription
barobjectThe progress bar object

SmartCart.calculatePercentageWithSubscriptionProductnumber

Calculates the progress bar's percentage when there is a Free Shipping On Subscription option enabled + satisfied

Returns: number - The percentage as a number

ParamTypeDescription
barobjectThe progress bar object

SmartCart.freeProductOptionsArray

Gets the options for a free gift product - either all variants or selected variants

Returns: Array - Array of variant objects

ParamTypeDescription
productobjectThe product object (from the earnedProducts array)

SmartCart.freeProductPromptstring

Gets text for the Free Product button - based on the product's status

Returns: string - The text for the button

ParamTypeDescription
productobjectThe product object

SmartCart.freeProductStylesobject | void

Gets the product's background image / styles

Returns: object | void - The styles object

ParamTypeDescription
productobjectThe product object

freeProductTileStyle ⇒ object | undefined

Deprecated

Gets the product's tile width, based on the number of earned products

Returns: object | undefined - The styles object

ParamTypeDescription
barobjectThe progress bar object

SmartCart.getBarForLocationobject

Get progress bar settings based on location

Returns: object - Progress bar settings object for the current location or default bar

ParamTypeDescription
countryCodestringCountry code for the current location

SmartCart.getCurrentTierobject | null

Gets current tier

Returns: object | null - Returns a tier object or null

ParamTypeDescription
barobjectThe progress bar object

SmartCart.getEarnedProductsArray.