Base Methods

SmartCart.currencystring

Gets the current cart currency code

SmartCart.destroy

Destroys the Smart Cart instance, removes it from the DOM, unbinds events, and resets default properties

SmartCart.discountTotalstring

Gets the discount total string to display in the Smart Cart

SmartCart.emptyCartMarkupstring

Gets the empty cart markup from the settings object

SmartCart.enrich

Enriches the cart product data, either pulling it from local storage or re-fetching it

SmartCart.formatMoneystring

Formats a money amount with the specified format and current cart currency (used to render money amounts in the Smart Cart)

SmartCart.getCalculatedCartDiscountnumber

Gets the calculated discount for the cart, based on detected automatic discounts OR applied discount codes

SmartCart.getComponentsByTypeArray

Gets all of the Smart Cart components of a specific type from the settings.components array

SmartCart.getFirstComponentByTypeobject | undefined

Gets the first Smart Cart component of a specific type from the settings.components array. This is useful for components that should only have one instance (ie. the title component)

SmartCart.getOriginalCartTotalnumber

Gets the cart original price (before discounts). Some items are excluded from the subtotal calculation.

SmartCart.getVueConfigobject

Defines the Smart Cart's Vue configuration object

SmartCart.hide

Hides the Smart Cart from the customer, stops any announcement bars, and triggers the Smart Cart hide event

SmartCart.init

Initializes the Smart Cart

SmartCart.isComponentVisibleboolean

Determines whether a Smart Cart component is visible based on its visibility status

SmartCart.setCart

Sets the internal SmartCart.cart object, syncs the cart note (if applicable), and enriches the cart product data

SmartCart.shouldUseProductMetafieldsboolean

Gets the setting value for Enable Product Metafields in the Smart Cart (used to determine whether to include product metafields in the Smart Cart enriched data)

SmartCart.show

Shows the Smart Cart to the customer, initializes any announcement bars, and triggers the Smart Cart show event

SmartCart.sizeImagestring

Gets a Shopify image size URL with a specified size

SmartCart.updateCartCount

Updates the Cart Item Count element with the current item count (if the Item Count selector is defined in the Theme Selectors in settings)

SmartCart.updateCartSubtotal

Updates the Cart Subtotal element with the current subtotal (if the Cart Subtotal selector is defined in the Theme Selectors in settings)

SmartCart.updateLiveRegion

Updates the ARIA Live Region in the Smart Cart with a message

SmartCart.currencystring

Gets the current cart currency code

Returns: string - the currency code for the current Shopify cart object

SmartCart.destroy

Destroys the Smart Cart instance, removes it from the DOM, unbinds events, and resets default properties

SmartCart.discountTotalstring

Gets the discount total string to display in the Smart Cart

Returns: string - The total discount amount (formatted)

ParamTypeDescription
formatstringMoney formatting string (ie. '${{amount}}')

SmartCart.emptyCartMarkupstring

Gets the empty cart markup from the settings object

Returns: string - The empty cart markup

SmartCart.enrich

Enriches the cart product data, either pulling it from local storage or re-fetching it

SmartCart.formatMoneystring

Formats a money amount with the specified format and current cart currency
(used to render money amounts in the Smart Cart)

Returns: string - The formatted money amount

ParamTypeDescription
amountnumber | stringThe money amount to format
[format]stringMoney formatting string (ie. '${{amount}}')
[currencyCode]stringThe currency code to use for formatting

SmartCart.getCalculatedCartDiscountnumber

Gets the calculated discount for the cart, based on detected automatic discounts OR applied discount codes

Returns: number - The total discount amount for the cart

SmartCart.getComponentsByTypeArray

Gets all of the Smart Cart components of a specific type from the settings.components array

Returns: Array - An array of Smart Cart components of the specified type

ParamTypeDescription
typestringThe component type to filter by

SmartCart.getFirstComponentByTypeobject | undefined

Gets the first Smart Cart component of a specific type from the settings.components array.
This is useful for components that should only have one instance (ie. the title component)

Returns: object | undefined - The first Smart Cart component of the specified type

ParamTypeDescription
typestringThe component type to filter by

SmartCart.getOriginalCartTotalnumber

Gets the cart original price (before discounts). Some items are excluded from the subtotal calculation.

Returns: number - The original price of the cart (included items original prices combined)

SmartCart.getVueConfigobject

Defines the Smart Cart's Vue configuration object

Returns: object - Vue configuration object

SmartCart.hide

Hides the Smart Cart from the customer, stops any announcement bars, and triggers the Smart Cart hide event

ParamTypeDescription
eeventThe event object (if applicable)

SmartCart.init

Initializes the Smart Cart

ParamTypeDescription
settingsobjectThe Smart Cart settings object

SmartCart.isComponentVisibleboolean

Determines whether a Smart Cart component is visible based on its visibility status

Returns: boolean - Whether the component is visible

ParamTypeDescription
componentobjectA Smart Cart component object from the settings.components array

SmartCart.setCart

Sets the internal SmartCart.cart object, syncs the cart note (if applicable), and enriches the cart product data

ParamTypeDescription
cartobjectThe Shopify cart object to set as the Smart Cart cart

SmartCart.shouldUseProductMetafieldsboolean

Gets the setting value for Enable Product Metafields in the Smart Cart
(used to determine whether to include product metafields in the Smart Cart enriched data)

Returns: boolean - Whether the setting is enabled

SmartCart.show

Shows the Smart Cart to the customer, initializes any announcement bars, and triggers the Smart Cart show event

ParamTypeDescription
eeventThe event object (if applicable)

SmartCart.sizeImagestring

Gets a Shopify image size URL with a specified size

Returns: string - The new image URL with the specified size

ParamTypeDescription
srcstringThe original image URL
sizestringThe desired image size (ie. 'small', 'medium', 'large')

SmartCart.updateCartCount

Updates the Cart Item Count element with the current item count
(if the Item Count selector is defined in the Theme Selectors in settings)

SmartCart.updateCartSubtotal

Updates the Cart Subtotal element with the current subtotal
(if the Cart Subtotal selector is defined in the Theme Selectors in settings)

SmartCart.updateLiveRegion

Updates the ARIA Live Region in the Smart Cart with a message

ParamTypeDescription
messagestringThe message to display in the live region