All methods below are as if the Smart Cart object has a reference variable defined as shown in this code snippet.
const SmartCart = window.Rebuy.SmartCart;
This is not a complete list of the globally available function but the ones that we find most helpful.
Overview
- getAnnouncementBarsInCart ⇒
Array
Get announcement bar instances used in the cart
- getAnnouncementsByComponentId ⇒
Array
Get announcements by component ID
- itemIsBundle ⇒
boolean
Check whether item is a bundle product
- itemBundleLength ⇒
boolean
Check if item is bundle and has more than 1 option
- childBundleTitle ⇒
string
Remove extra word from bundle option title
- isBundleVisible ⇒
boolean
Check whether the item is the currently expanded bundle
- toggleActiveBundle ⇒
void
Toggle the active product bundle
- getBundleOptionImage ⇒
string
Get the bundle option image
- itemHasBMSM ⇒
boolean
|void
Checks if the provided item has Buy More Save More (BMSM) discount enabled.
- hasBMSMButtons ⇒
boolean
Checks if the BMSM discount is displayed as buttons.
- getBMSMTiers ⇒
Array
Gets the BMSM tiers.
- getBMSMButtonText ⇒
string
Gets the BMSM discount button text for the provided tier.
- adjustBMSMQuantity ⇒
void
Adjusts the BMSM quantity for the provided item and tier.
- buyMoreSaveMoreDynamicText ⇒
string
|void
Gets the dynamic BMSM discount text for the provided item.
- bMSMFinalTierNotReached ⇒
boolean
Checks if the final BMSM tier has been reached for the provided item.
- getCheckoutSettings ⇒
object
gets the checkout settings from the SmartCart
- hasTermsEnabled ⇒
boolean
Determines if the terms and conditions are enabled in settings
- hasAcceptedTerms ⇒
boolean
Checks if the user has accepted the terms and conditions
- updateTermsCheck ⇒
void
Update the terms checkbox status
- hasCheckoutButton ⇒
boolean
Checks if the checkout button is enabled
- checkout ⇒
void
Performs the checkout process
- shopPayCheckout ⇒
void
Performs the Shop Pay checkout process
- shopPaySvg :
string
SVG code for the Shop Pay icon.
- checkoutLabel ⇒
string
Gets the label for the checkout button
- hasViewCartButton ⇒
boolean
Checks if the View Cart button is enabled
- viewCart ⇒
void
Navigates to the Shopify Cart Page
- viewCartLabel ⇒
string
Gets the label for the View Cart button
- hasContinueShoppingButton ⇒
boolean
Checks if the Continue Shopping button is enabled
- continueShoppingLabel ⇒
string
Get the label for the Continue Shopping button
- hasShopPayButton ⇒
boolean
Checks if the Shop Pay button is enabled
- installmentsEnabled ⇒
boolean
Returns true if the payment installments indicator text is enabled
- installmentsMessage ⇒
string
Returns the payment installments indicator text
- hasPrePurchase ⇒
boolean
Returns true if there is a pre-purchase pop-up widget enabled
- prePurchaseWidgetId ⇒
string
Returns the pre-purchase pop-up widget ID
- getAdditionalCheckoutButtons ⇒
boolean
|Array.<Element>
Checks for the existence of the '.additional-checkout-buttons' element, which is used by the 'rebuy-smartcart-extensions.liquid' snippet
- appendAcceleratedCheckout ⇒
void
Appends the '.additional-checkout-buttons' element to the SmartCart flyout
- getPreviewButtons ⇒
Element
Returns the Accelerated Checkout buttons for previewing in the Admin
- adjustPreviewButtons ⇒
void
Updates the Accelerated Checkout buttons for previewing in the Admin.
- clearAcceleratedCheckout ⇒
void
Removes the '.additional-checkout-buttons' element from the SmartCart flyout
- renderPayPalButton ⇒
void
Conditionally renders a paypal button if the PayPal iFrame is not rendered
- manageAcceleratedCheckout ⇒
void
Manages the Accelerated Checkout feature
- getAllCrossSellWidgetIds ⇒
Array.<string>
Get all cross sell widget IDs in Cross-Sell components in the current Smart Cart settings
- hasCrossSellWidgets ⇒
boolean
Check if there are cross sell widgets in the current Smart Cart settings
- getWidgetIdByComponentId ⇒
string
|null
Get the widget ID by component ID
- executeCustomCode ⇒
void
Executes the custom code -- in case there is any JS that needs to be executed
- injectCustomCodeBlocks ⇒
void
Injects the custom code HTML into the DOM
- getDiscountCodeSettings ⇒
object
|null
Get the discount code settings from the current SmartCart instance
- getDiscountCodeLabel ⇒
string
Get the discount code label from the current SmartCart instance
- getDiscountButtonLabel ⇒
string
Get the discount button label from the current SmartCart instance
- getDiscountInvalidMessage ⇒
string
Get the discount invalid message from the current SmartCart instance
- applyDiscount ⇒
void
Applies a discount code to the current SmartCart instance.
- showInvalidMessage ⇒
boolean
Determines if the invalid message should be shown.
- shouldShowDiscountEntitled ⇒
boolean
Determines if the discount entitled message should be shown.
- shouldShowDiscountInput ⇒
boolean
Determines if the discount input should be shown.
- shouldShowDiscountSubtotal ⇒
boolean
Determines if the discount subtotal should be shown.
- shouldApplyDiscountCode ⇒
boolean
Determines, based on the presence of an automatic discount, if the discount code should be applied.
- useDiscountCodeMessageOnly ⇒
boolean
Determines if the discount calculation should be omitted (useful for complex discount scenarios).
- removeDiscount ⇒
void
Removes the discount from the current SmartCart instance + local storage.
- isDiscountInputEnabled ⇒
boolean
Determines if the discount code input component is enabled.
- getLoginLabel ⇒
string
Get the login button text from the current SmartCart instance
- getLoginUrl ⇒
string
Get the login button URL from the current SmartCart instance
- shouldRenderLoginComponent ⇒
boolean
Check if the login component should be rendered
- getNotesSettings ⇒
object
Returns the notes settings from the SmartCart object.
- getNotesData ⇒
object
|null
Returns the notes state data from the SmartCart object (not the settings).
- getNotesLabel ⇒
string
Returns the configured label for the notes input
- getNotesPlaceholder ⇒
string
Returns the configured placeholder for the notes input
- notesEnabled ⇒
boolean
Returns a boolean indicating whether or not the notes component is enabled (ie. not hidden)
- notesIsVisible ⇒
boolean
Returns a boolean indicating whether or not the notes input is visible to customer
- notesToggle ⇒
void
Handles toggling the visibility of the notes input
- notesChange ⇒
void
Handles updating the notes value
- notesRemainingCharacters ⇒
string
Returns a string containing the remaining characters message
- isEnabled ⇒
boolean
Determine if the SwitchToSubscription functionality is enabled + available
- hasSwitchToSubscription ⇒
boolean
Determine if the item has the SwitchToSubscription functionality
- subscriptionDowngradeDisabled ⇒
boolean
Determine if the SmartCart subscription downgrade functionality is disabled
- getLabel ⇒
string
Get the SwitchToSubscription label string
- switchToSubscriptionLabel ⇒
string
Get the SwitchToSubscription label string for the item
- subscriptionOptionGroupLabel ⇒
string
Get the SwitchToSubscription subscription option group label string
- subscriptionOptionLabel ⇒
string
|number
|void
Get the SwitchToSubscription subscription option label string
- getSettings() ⇒
object
Get the settings for the SwitchToSubscription functionality
- getBarForLocation ⇒
object
Get progress bar settings based on location
- isProgressBarEnabled ⇒
boolean
Determine if the progress bar is enabled
- getProgressBarSettings ⇒
object
Get the progress bar settings object
- hasProgressPrompt ⇒
boolean
|string
Determine if the progress bar has a prompt for the current tier
- getTierCompletedText ⇒
string
Get the text for the completed tier
- getTierFeedbackText ⇒
string
Get the text for the current tier (either in progress or completed)
- getCurrentTier ⇒
object
|null
Gets current tier
- getTierMinimum ⇒
number
|null
Gets the minimum threshold for a given tier
- getTierLabel ⇒
string
Gets the label for a given tier
- progressStepMaxWidth ⇒
string
Utility helper for getting the max width of the tiers for CSS
- progressTierIcon ⇒
string
Utility helper for getting the icon for a given tier
- tierProgressIcon ⇒
string
Utility helper for getting the icon for a given tier (In Progress)
- tierCompleteIcon ⇒
string
Utility helper for getting the icon for a given tier (Complete)
- hasTierProgress ⇒
boolean
Determine if there is any progress to show in the progress bar
- hasFreeShippingOnSubscription ⇒
boolean
Determine if Free Shipping should be satisfied by a subscription product in the Cart
- calculatePercentageWithSubscriptionProduct ⇒
number
Calculates the progress bar's percentage when there is a Free Shipping On Subscription option enabled + satisfied
- calculatePercentageWithNormalTierMinimums ⇒
number
Calculates the progress bar's percentage when there is no Free Shipping On Subscription option enabled / satisfied
- tiersPercentageComplete ⇒
string
|number
Calculates the progress bar's percentage completed
- progressTierReached ⇒
boolean
Determines if the tier has been reached based on the subtotal
- getSpendToNextTier ⇒
number
Gets the difference between the subtotal and the next tier's minimum
- getEarnedProducts ⇒
Array
Gets the list of earned products from the bar
- freeProductPrompt ⇒
string
|void
Gets text for the Free Product button - based on the product's status
- freeProductStyles ⇒
object
|void
Gets the product's background image / styles
- freeProductTileStyle ⇒
object
|void
Gets the product's tile width, based on the number of earned products
- getFreeVariantTitle ⇒
string
Gets the product's title, if it's not the default title
- removeAllFreeGifts ⇒
void
Removes all cart products with the _attribution property set to ITEM_ATTRIBUTION.TIERED_PROGRESS_BAR
- updateFreeProducts ⇒
void
Updates the free products in the cart based on the current subtotal. This contains the primary logic for the progress bar cart management
- selectFreeProductVariant
Handles the selection of a free gift variant in the bar
- freeProductOptions ⇒
Array
Gets the options for a free gift product - either all variants or selected variants
- addFreeProduct ⇒
void
Adds a free gift to the cart
- removeFreeProduct ⇒
void
Removes a free product from the cart + updates the declined gifts cookie
- getTieredBarProductData ⇒
object
Checks local storage for cached product data, and fetches any missing product data from the API
getAnnouncementBarsInCart
Get announcement bar instances used in the cart
Kind: global constant
Returns: Array
- The announcement bar instances
getAnnouncementsByComponentId
Get announcements by component ID
Kind: global constant
Returns: Array
- The announcements for the component
Param | Type | Description |
---|---|---|
id | string | The component ID |
itemIsBundle
Check whether item is a bundle product
Kind: global constant
Returns: boolean
- true if item is bundle
Param | Type | Description |
---|---|---|
item | object | line item |
itemBundleLength
Check if item is bundle and has more than 1 option
Kind: global constant
Returns: boolean
- true if item is bundle and has more than 1 option
Param | Type | Description |
---|---|---|
item | object | line item |
childBundleTitle
Remove extra word from bundle option title
Kind: global constant
Returns: string
- bundle option title
Param | Type | Description |
---|---|---|
option | object | bundle option |
isBundleVisible
Check whether the item is the currently expanded bundle
Kind: global constant
Returns: boolean
- true if the item is the currently expanded bundle
Param | Type | Description |
---|---|---|
item | object | line item |
toggleActiveBundle
Toggle the active product bundle
Kind: global constant
Param | Type | Description |
---|---|---|
item | object | line item |
getBundleOptionImage
Get the bundle option image
Kind: global constant
Returns: string
- Image URL
Param | Type | Description |
---|---|---|
product | object | Product object |
currentOption | object | Current option |
currentOptionIndex | number | Index of the current option |
itemHasBMSM
Checks if the provided item has Buy More Save More (BMSM) discount enabled.
Kind: global constant
Returns: boolean
| void
- True if the item has BMSM discount enabled, false otherwise.
Param | Type | Description |
---|---|---|
item | object | The item to check for BMSM discount. |
hasBMSMButtons
Checks if the BMSM discount is displayed as buttons.
Kind: global constant
Returns: boolean
- - True if the BMSM discount is displayed as buttons, false otherwise.
getBMSMTiers
Gets the BMSM tiers.
Kind: global constant
Returns: Array
- - An array of BMSM discount tiers.
getBMSMButtonText
Gets the BMSM discount button text for the provided tier.
Kind: global constant
Returns: string
- - The BMSM discount button text for the provided tier.
Param | Type | Description |
---|---|---|
tier | object | The BMSM tier for which to get the button text. |
adjustBMSMQuantity
Adjusts the BMSM quantity for the provided item and tier.
Kind: global constant
Param | Type | Description |
---|---|---|
item | object | The item for which to adjust the BMSM quantity. |
tier | object | The BMSM tier for which to adjust the quantity. |
buyMoreSaveMoreDynamicText
Gets the dynamic BMSM discount text for the provided item.
Kind: global constant
Returns: string
| void
- The dynamic BMSM discount text for the provided item.
Param | Type | Description |
---|---|---|
item | object | The item for which to get the dynamic BMSM discount text. |
bMSMFinalTierNotReached
Checks if the final BMSM tier has been reached for the provided item.
Kind: global constant
Returns: boolean
- - True if the final BMSM tier has not been reached, false otherwise.
Param | Type | Description |
---|---|---|
item | object | The item for which to check if the final BMSM tier has been reached. |
getCheckoutSettings
gets the checkout settings from the SmartCart
Kind: global constant
Returns: object
- - The checkout settings object
hasTermsEnabled
Determines if the terms and conditions are enabled in settings
Kind: global constant
Returns: boolean
- - True if terms and conditions are enabled, otherwise false
hasAcceptedTerms
Checks if the user has accepted the terms and conditions
Kind: global constant
Returns: boolean
- - True if the user has accepted the terms, otherwise false
updateTermsCheck
Update the terms checkbox status
hasCheckoutButton
Checks if the checkout button is enabled
Kind: global constant
Returns: boolean
- - True if the checkout button is enabled, otherwise false
checkout
Performs the checkout process
shopPayCheckout
Performs the Shop Pay checkout process
shopPaySvg
SVG code for the Shop Pay icon.
checkoutLabel
Gets the label for the checkout button
Kind: global constant
Returns: string
- - The label for the checkout button (HTML content)
hasViewCartButton
Checks if the View Cart button is enabled
Kind: global constant
Returns: boolean
- - True if the View Cart button is enabled, otherwise false
viewCart
Navigates to the Shopify Cart Page
viewCartLabel
Gets the label for the View Cart button
Kind: global constant
Returns: string
- - The label for the View Cart button
hasContinueShoppingButton
Checks if the Continue Shopping button is enabled
Kind: global constant
Returns: boolean
- - True if the Continue Shopping button is enabled, otherwise false
continueShoppingLabel
Get the label for the Continue Shopping button
Kind: global constant
Returns: string
- - The label for the Continue Shopping button
hasShopPayButton
Checks if the Shop Pay button is enabled
Kind: global constant
Returns: boolean
- - True if the Shop Pay button is enabled, otherwise false
installmentsEnabled
Returns true if the payment installments indicator text is enabled
installmentsMessage
Returns the payment installments indicator text
Kind: global constant
Returns: string
- HTML
hasPrePurchase
Returns true if there is a pre-purchase pop-up widget enabled
prePurchaseWidgetId
Returns the pre-purchase pop-up widget ID
getAdditionalCheckoutButtons
Checks for the existence of the '.additional-checkout-buttons' element, which is used by the 'rebuy-smartcart-extensions.liquid' snippet
Kind: global constant
Param | Type | Description |
---|---|---|
parent | Element | DOM Element |
appendAcceleratedCheckout
Appends the '.additional-checkout-buttons' element to the SmartCart flyout
getPreviewButtons
Returns the Accelerated Checkout buttons for previewing in the Admin
Kind: global constant
Param | Type | Description |
---|---|---|
settings | object | Smart Cart Settings |
adjustPreviewButtons
Updates the Accelerated Checkout buttons for previewing in the Admin.
Kind: global constant
Param | Type | Description |
---|---|---|
settings | object | Smart Cart settings |
clearAcceleratedCheckout
Removes the '.additional-checkout-buttons' element from the SmartCart flyout
renderPayPalButton
Conditionally renders a paypal button if the PayPal iFrame is not rendered
manageAcceleratedCheckout
Manages the Accelerated Checkout feature
Kind: global constant
getAllCrossSellWidgetIds
Get all cross sell widget IDs in Cross-Sell components in the current Smart Cart settings
Kind: global constant
Returns: Array.
- Array of widget IDs
hasCrossSellWidgets
Check if there are cross sell widgets in the current Smart Cart settings
Kind: global constant
Returns: boolean
- True if there are cross sell widgets
getWidgetIdByComponentId
Get the widget ID by component ID
Kind: global constant
Returns: string
| null
- The widget ID
Param | Type | Description |
---|---|---|
componentId | string | The component ID |
executeCustomCode
Executes the custom code -- in case there is any JS that needs to be executed
injectCustomCodeBlocks
Injects the custom code HTML into the DOM
Kind: global constant
getDiscountCodeSettings
Get the discount code settings from the current SmartCart instance
Kind: global constant
Returns: object
| null
- The discount code component settings
getDiscountCodeLabel
Get the discount code label from the current SmartCart instance
Kind: global constant
Returns: string
- The discount code label text
getDiscountButtonLabel
Get the discount button label from the current SmartCart instance
Kind: global constant
Returns: string
- The discount button text
getDiscountInvalidMessage
Get the discount invalid message from the current SmartCart instance
Kind: global constant
Returns: string
- The discount invalid message text
applyDiscount
Applies a discount code to the current SmartCart instance.
Kind: global constant
Param | Type | Description |
---|---|---|
discountCode | string | The discount code to apply. |
[e] | Event | The event object (optional). |
showInvalidMessage
Determines if the invalid message should be shown.
Kind: global constant
Returns: boolean
- Whether the invalid message should be shown.
shouldShowDiscountEntitled
Determines if the discount entitled message should be shown.
Kind: global constant
Returns: boolean
- Whether the discount entitled message should be shown.
shouldShowDiscountInput
Determines if the discount input should be shown.
Kind: global constant
Returns: boolean
- Whether the discount input should be shown.
shouldShowDiscountSubtotal
Determines if the discount subtotal should be shown.
Kind: global constant
Returns: boolean
- Whether the discount subtotal should be shown.
shouldApplyDiscountCode
Determines, based on the presence of an automatic discount, if the discount code should be applied.
Kind: global constant
Returns: boolean
- Whether the discount code should be applied.
useDiscountCodeMessageOnly
Determines if the discount calculation should be omitted (useful for complex discount scenarios).
Kind: global constant
Returns: boolean
- Whether the discount calculation should be omitted until checkout.
removeDiscount
Removes the discount from the current SmartCart instance + local storage.
isDiscountInputEnabled
Determines if the discount code input component is enabled.
Kind: global constant
getLoginLabel
Get the login button text from the current SmartCart instance
Kind: global constant
Returns: string
- The login button text
getLoginUrl
Get the login button URL from the current SmartCart instance
Kind: global constant
Returns: string
- The login button URL
shouldRenderLoginComponent
Check if the login component should be rendered
Kind: global constant
Returns: boolean
- True if the login component should be rendered
getNotesSettings
Returns the notes settings from the SmartCart object.
getNotesData
Returns the notes state data from the SmartCart object (not the settings).
getNotesLabel
Returns the configured label for the notes input
getNotesPlaceholder
Returns the configured placeholder for the notes input
notesEnabled
Returns a boolean indicating whether or not the notes component is enabled (ie. not hidden)
notesIsVisible
Returns a boolean indicating whether or not the notes input is visible to customer
notesToggle
Handles toggling the visibility of the notes input
notesChange
Handles updating the notes value
Kind: global constant
Param | Type | Description |
---|---|---|
event | Event | DOM user action event |
notesRemainingCharacters
Returns a string containing the remaining characters message
Kind: global constant
executeApps
Executes the app scripts
injectAppScripts
Injects the app scripts into the DOM
Kind: global constant
Param | Type | Description |
---|---|---|
cartSettings | object | Smart Cart settings |
enrichApps
Hydrates apps with data from API
Kind: global constant
Param | Type | Description |
---|---|---|
cartSettings | object | Smart Cart settings |
getSubtotalSettings
Returns the subtotal settings from the SmartCart components array.
subtotalLabel
Returns the subtotal label.
subtotal
Returns the subtotal amount to display. The subtotal is often just a formatted string, but can be returned as HTML to display a compare (discount) price
Kind: global constant
Param | Type | Description |
---|---|---|
format | string | Currency format string |
isEnabled
Determine if the SwitchToSubscription functionality is enabled + available
Kind: global constant
Returns: boolean
- response
hasSwitchToSubscription
Determine if the item has the SwitchToSubscription functionality
Kind: global constant
Returns: boolean
- response
Param | Type | Description |
---|---|---|
item | object | rebuy cart item |
subscriptionDowngradeDisabled
Determine if the SmartCart subscription downgrade functionality is disabled
Kind: global constant
Returns: boolean
- response
getLabel
Get the SwitchToSubscription label string
Kind: global constant
Returns: string
- label
Param | Type | Description |
---|---|---|
property | string | property to get from the language object |
switchToSubscriptionLabel
Get the SwitchToSubscription label string for the item
Kind: global constant
Returns: string
- label
Param | Type | Description |
---|---|---|
item | object | rebuy cart item |
subscriptionOptionGroupLabel
Get the SwitchToSubscription subscription option group label string
Kind: global constant
Returns: string
- label
Param | Type | Description |
---|---|---|
item | object | rebuy cart item |
subscriptionOptionLabel
Get the SwitchToSubscription subscription option label string
Kind: global constant
Returns: string
| number
| void
- label | frequency
Param | Type | Description |
---|---|---|
item | object | rebuy cart item |
frequency | number | subscription frequency (number of times per interval) |
interval | string | subscription interval (day, week, month, year) |
getSettings
Get the settings for the SwitchToSubscription functionality
Kind: global function
Returns: object
- settings
getBarForLocation
Get progress bar settings based on location
Kind: global constant
Returns: object
- Progress bar settings object for the current location or default bar
Param | Type | Description |
---|---|---|
countryCode | string | Country code for the current location |
isProgressBarEnabled
Determine if the progress bar is enabled
Kind: global constant
Returns: boolean
- - Boolean indicating whether the progress bar is enabled or not
getProgressBarSettings
Get the progress bar settings object
Kind: global constant
Returns: object
- - The progress bar object | null
hasProgressPrompt
Determine if the progress bar has a prompt for the current tier
Kind: global constant
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 |
getTierCompletedText
Get the text for the completed tier
Kind: global constant
Returns: string
- - The completed tier text
Param | Type | Description |
---|---|---|
bar | object | The progress bar object |
tier | object | The tier object |
getTierFeedbackText
Get the text for the current tier (either in progress or completed)
Kind: global constant
Returns: string
- - The current tier text
Param | Type | Description |
---|---|---|
bar | object | The progress bar object |
getCurrentTier
Gets current tier
Kind: global constant
Returns: object
| null
- - Returns a tier object or null
Param | Type | Description |
---|---|---|
bar | object | The progress bar object |
getTierMinimum
Gets the minimum threshold for a given tier
Kind: global constant
Returns: number
| null
- - Returns the minimum threshold as a number or null
Param | Type | Description |
---|---|---|
tier | object | The tier object |
getTierLabel
Gets the label for a given tier
Kind: global constant
Returns: string
- - Returns the label as a string
Param | Type | Description |
---|---|---|
tier | object | The tier object |
progressStepMaxWidth
Utility helper for getting the max width of the tiers for CSS
Kind: global constant
Returns: string
- - Returns the max width as a string (percentage for CSS)
Param | Type | Description |
---|---|---|
bar | object | The progress bar object |
progressTierIcon
Utility helper for getting the icon for a given tier
Kind: global constant
Returns: string
- - Returns the icon as an HTML string
Param | Type | Description |
---|---|---|
tier | object | The tier object |
tierProgressIcon
Utility helper for getting the icon for a given tier (In Progress)
Kind: global constant
Returns: string
- - Returns the icon as an HTML string
Param | Type | Description |
---|---|---|
tier | object | The tier object |
tierCompleteIcon
Utility helper for getting the icon for a given tier (Complete)
Kind: global constant
Returns: string
- - Returns the icon as an HTML string
Param | Type | Description |
---|---|---|
tier | object | The tier object |
hasTierProgress
Determine if there is any progress to show in the progress bar
hasFreeShippingOnSubscription
Determine if Free Shipping should be satisfied by a subscription product in the Cart
calculatePercentageWithSubscriptionProduct
Calculates the progress bar's percentage when there is a Free Shipping On Subscription option enabled + satisfied
Kind: global constant
Param | Type | Description |
---|---|---|
bar | object | The progress bar object |
calculatePercentageWithNormalTierMinimums
Calculates the progress bar's percentage when there is no Free Shipping On Subscription option enabled / satisfied
Kind: global constant
Param | Type | Description |
---|---|---|
bar | object | The progress bar object |
tiersPercentageComplete
Calculates the progress bar's percentage completed
Kind: global constant
Param | Type | Description |
---|---|---|
bar | object | The progress bar object |
returnInt | boolean | Indicates whether to return an integer or a string |
progressTierReached
Determines if the tier has been reached based on the subtotal
Kind: global constant
Param | Type | Description |
---|---|---|
tier | object | The tier object |
getSpendToNextTier
Gets the difference between the subtotal and the next tier's minimum
Kind: global constant
Param | Type | Description |
---|---|---|
bar | object | The progress bar object |
getEarnedProducts
Gets the list of earned products from the bar
Kind: global constant
Param | Type | Description |
---|---|---|
bar | object | The progress bar object |
freeProductPrompt
Gets text for the Free Product button - based on the product's status
Kind: global constant
Param | Type | Description |
---|---|---|
product | object | The product object |
freeProductStyles
Gets the product's background image / styles
Kind: global constant
Returns: object
| void
- The styles object
Param | Type | Description |
---|---|---|
product | object | The product object |
freeProductTileStyle
Gets the product's tile width, based on the number of earned products
Kind: global constant
Returns: object
| void
- The styles object
Param | Type | Description |
---|---|---|
bar | object | The progress bar object |
getFreeVariantTitle
Gets the product's title, if it's not the default title
Kind: global constant
Param | Type | Description |
---|---|---|
product | object | The product object |
removeAllFreeGifts
Removes all cart products with the _attribution property set to ITEM_ATTRIBUTION.TIERED_PROGRESS_BAR
updateFreeProducts
Updates the free products in the cart based on the current subtotal. This contains the primary logic for the progress bar cart management
selectFreeProductVariant
Handles the selection of a free gift variant in the bar
Kind: global constant
Param | Type | Description |
---|---|---|
event | object | The event object |
product | object | The product object |
freeProductOptions
Gets the options for a free gift product - either all variants or selected variants
Kind: global constant
Returns: Array
- - Array of variant objects
Param | Type | Description |
---|---|---|
product | object | The product object |
addFreeProduct
Adds a free gift to the cart
Kind: global constant
Param | Type | Description |
---|---|---|
product | object | The product object |
removeFreeProduct
Removes a free product from the cart + updates the declined gifts cookie
Kind: global constant
Param | Type | Description |
---|---|---|
product | object | The product object |
getTieredBarProductData
Checks local storage for cached product data, and fetches any missing product data from the API
Kind: global constant
Returns: object
- The updated progress bar object
Param | Type | Description |
---|---|---|
bar | object | The progress bar object |
getCartTitleHeadingTag
Get the cart title heading tag (h1, h2, h3, etc.)
Kind: global constant
Returns: string
- the heading tag level for the cart title
getCartTitle
Get the cart title
Kind: global constant
Returns: string
- the cart title text
getCartTitleClassName
Get the dynamic cart title class name - important for sr-only class
Kind: global constant
Returns: string
- the dynamic cart title class name