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

Param

Type

Description

product

object

The 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)

Param

Type

Description

product

object

The 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

Param

Type

Description

bar

object

The 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

Param

Type

Description

bar

object

The 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

Param

Type

Description

product

object

The 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

Param

Type

Description

product

object

The product object

SmartCart.freeProductStylesobject | void

Gets the product's background image / styles

Returns: object | void - The styles object

Param

Type

Description

product

object

The 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

Param

Type

Description

bar

object

The 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

Param

Type

Description

countryCode

string

Country code for the current location

SmartCart.getCurrentTierobject | null

Gets current tier

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

Param

Type

Description

bar

object

The progress bar object

SmartCart.getEarnedProductsArray.<object>

Gets the list of earned products from the bar

Returns: Array.<object> - The list of earned products

Param

Type

Description

bar

object

The progress bar object

SmartCart.getFreeVariantTitlestring

Gets the gift product's variant title

Returns: string - The applied gift variant title

Param

Type

Description

product

object

The product object

SmartCart.getGiftAreaTitlestring

Gets the Gift Area Title to display above the Gift Area

Returns: string - The Gift Area Title

Param

Type

Description

bar

object

The progress bar object

SmartCart.getProductsWithoutSelectionArray.<object>

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

Returns: Array.<object> - The earned products in the cart that don't have a variant selected

Param

Type

Description

bar

object

The progress bar object

SmartCart.getProgressBarSettingsobject | null

Get the progress bar settings object

Returns: object | null - The progress bar settings object | null\

SmartCart.getProgressStepIconSizeobject

Utility helper for getting the style object with configured sizes

Returns: object - Returns the style object with width and height defined for the image

Param

Type

Description

tier

object

The tier object

SmartCart.getSpendToNextTiernumber

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

Returns: number - The difference as a number

Param

Type

Description

bar

object

The progress bar object

SmartCart.getTierCompletedTextstring

Get the text for the completed tier

Returns: string - The completed tier text

Param

Type

Description

bar

object

The progress bar object

tier

object

The tier object

SmartCart.getTierFeedbackTextstring

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

Returns: string - The current tier text

Param

Type

Description

bar

object

The progress bar object

SmartCart.getTierLabelstring

Gets the step label for a given tier

Returns: string - Returns the label as a string

Param

Type

Description

tier

object

The tier object

SmartCart.getTierMinimumnumber | null

Gets the minimum threshold for a given tier

Returns: number | null - Returns the minimum threshold as a number or null

Param

Type

Description

tier

object

The tier object

SmartCart.getTieredBarProductDataobject

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

Returns: object - The updated progress bar object

Param

Type

Description

bar

object

The progress bar object

SmartCart.hasFreeShippingOnSubscriptionboolean

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

Returns: boolean - Boolean indicating whether Free Shipping should be satisfied by a subscription product\

SmartCart.hasGiftSelectionboolean

Determine if the gift product requires a customer variant selection

Returns: boolean - Boolean indicating whether the gift product has a variant selection

Param

Type

Description

product

object

The gift product object

SmartCart.hasProgressPromptboolean | string

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

Returns: boolean | string - A boolean value or a truthy string indicating whether the progress bar has a prompt or not

Param

Type

Description

bar

object

The progress bar object

SmartCart.hasTierProgressboolean

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

Returns: boolean - Boolean indicating whether there is any progress to show\

SmartCart.isGiftItemboolean

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

Returns: boolean - Boolean indicating whether the item is a free gift item

Param

Type

Description

item

object

Shopify cart item object

SmartCart.isProgressBarEnabledboolean

Determine if the progress bar is enabled

Returns: boolean - Boolean indicating whether the progress bar is enabled or not\

SmartCart.progressBarSubtotalnumber

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

Returns: number - the current subtotal (with exclusions)\

SmartCart.progressStepMaxWidthstring

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

Returns: string - Returns the max width as a string (percentage for CSS)

Param

Type

Description

bar

object

The progress bar object

SmartCart.progressTierIconstring

Utility helper for getting the icon for a given tier

Returns: string - Returns the icon as an HTML string

Param

Type

Description

tier

object

The tier object

SmartCart.progressTierReachedboolean

Determines if the tier has been reached based on the subtotal

Returns: boolean - Boolean indicating whether the tier has been reached

Param

Type

Description

tier

object

The tier object

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

Param

Type

Description

product

object

The earned product object (from the bar.earnedProducts array)

callback

function

The callback function to run after the gift has been removed

SmartCart.selectFreeProductVariant

Handles the selection of a free gift variant in the bar

Param

Type

Description

event

object

The event object

product

object

The product object

SmartCart.shouldFilterOutOfStockVariantsFromTierboolean

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

Returns: boolean - Boolean indicating whether Out of Stock variants should be hidden for this tier

Param

Type

Description

tier

object

The tier object

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)

Returns: boolean - Boolean indicating whether the gift product should be rendered with the bar

Param

Type

Description

bar

object

The progress bar object

product

object

The gift product object

SmartCart.shouldRenderGiftAreaboolean

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

Returns: boolean - Boolean indicating whether the Gifts Area should be rendered

Param

Type

Description

bar

object

The progress bar object

SmartCart.shouldRenderGiftAreaTitleboolean

Determine if the Gift Area Title should be used

Returns: boolean - Boolean indicating whether the Gift Area Title should be used

Param

Type

Description

bar

object

The progress bar object

SmartCart.tierCompleteIconstring

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

Returns: string - Returns the icon as an HTML string

Param

Type

Description

tier

object

The tier object

SmartCart.tierProgressIconstring

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

Returns: string - Returns the icon as an HTML string

Param

Type

Description

tier

object

The tier object

SmartCart.tiersPercentageCompletestring | number

Calculates the progress bar's percentage completed

Returns: string | number - The percentage as a string or number

Param

Type

Description

bar

object

The progress bar object

returnInt

boolean

Indicates whether to return an integer or a string

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