Base Methods
- SmartCart.currency ⇒
string -
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.discountTotal ⇒
string -
Gets the discount total string to display in the Smart Cart
- SmartCart.emptyCartMarkup ⇒
string -
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.formatMoney ⇒
string -
Formats a money amount with the specified format and current cart currency (used to render money amounts in the Smart Cart)
- SmartCart.getCalculatedCartDiscount ⇒
number -
Gets the calculated discount for the cart, based on detected automatic discounts OR applied discount codes
- SmartCart.getComponentsByType ⇒
Array -
Gets all of the Smart Cart components of a specific type from the settings.components array
- SmartCart.getFirstComponentByType ⇒
object|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.getOriginalCartTotal ⇒
number -
Gets the cart original price (before discounts). Some items are excluded from the subtotal calculation.
- SmartCart.getVueConfig ⇒
object -
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.isComponentVisible ⇒
boolean -
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.shouldUseProductMetafields ⇒
boolean -
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.sizeImage ⇒
string -
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.skip_open
-
Property that can be overridden to prevent the cart from opening on product adds.
SmartCart.currency ⇒ string¶
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.discountTotal ⇒ string¶
Gets the discount total string to display in the Smart Cart
Returns: string - The total discount amount (formatted)
| Param | Type | Description |
|---|---|---|
| format |
string
|
Money formatting string (ie. `'${{amount}}'`) |
SmartCart.emptyCartMarkup ⇒ string¶
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.formatMoney ⇒ string¶
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
| Param | Type | Description |
|---|---|---|
| amount |
number \| string
|
The money amount to format |
| [format] |
string
|
Money formatting string (ie. `'${{amount}}'`) |
| [currencyCode] |
string
|
The currency code to use for formatting |
SmartCart.getCalculatedCartDiscount ⇒ number¶
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.getComponentsByType ⇒ Array¶
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
| Param | Type | Description |
|---|---|---|
| type |
string
|
The component type to filter by |
SmartCart.getFirstComponentByType ⇒ object | 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
| Param | Type | Description |
|---|---|---|
| type |
string
|
The component type to filter by |
SmartCart.getOriginalCartTotal ⇒ number¶
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.getVueConfig ⇒ object¶
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
| Param | Type | Description |
|---|---|---|
| e |
event
|
The event object (if applicable) |
SmartCart.init¶
Initializes the Smart Cart
| Param | Type | Description |
|---|---|---|
| settings |
object
|
The Smart Cart settings object |
SmartCart.isComponentVisible ⇒ boolean¶
Determines whether a Smart Cart component is visible based on its visibility status
Returns: boolean - Whether the component is visible
| Param | Type | Description |
|---|---|---|
| component |
object
|
A 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
| Param | Type | Description |
|---|---|---|
| cart |
object
|
The Shopify cart object to set as the Smart Cart cart |
SmartCart.shouldUseProductMetafields ⇒ boolean¶
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
| Param | Type | Description |
|---|---|---|
| e |
event
|
The event object (if applicable) |
SmartCart.sizeImage ⇒ string¶
Gets a Shopify image size URL with a specified size
Returns: string - The new image URL with the specified size
| Param | Type | Description |
|---|---|---|
| src |
string
|
The original image URL |
| size |
string
|
The 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
| Param | Type | Description |
|---|---|---|
| message |
string
|
The message to display in the live region |
SmartCart.skip_open¶
When this property is set to true, it will prevent Smart Cart from opening when an item is added to cart (clicking on cart icon will still allow the Smart Cart to open, however).
--- title: Base Methods excerpt: '' deprecated: false hidden: false metadata: title: '' description: '' robots: index next: description: Return to the New Methods Overview Page to see other available methods. pages: - type: endpoint slug: smart-cart-methods title: Methods Overview - New --- <dl> <dt><a href="#SmartCart.currency">SmartCart.currency</a> ⇒ <code>string</code></dt> <dd> <p>Gets the current cart currency code</p> </dd> <dt><a href="#SmartCart.destroy">SmartCart.destroy</a></dt> <dd> <p>Destroys the Smart Cart instance, removes it from the DOM, unbinds events, and resets default properties</p> </dd> <dt><a href="#SmartCart.discountTotal">SmartCart.discountTotal</a> ⇒ <code>string</code></dt> <dd> <p>Gets the discount total string to display in the Smart Cart</p> </dd> <dt><a href="#SmartCart.emptyCartMarkup">SmartCart.emptyCartMarkup</a> ⇒ <code>string</code></dt> <dd> <p>Gets the empty cart markup from the settings object</p> </dd> <dt><a href="#SmartCart.enrich">SmartCart.enrich</a></dt> <dd> <p>Enriches the cart product data, either pulling it from local storage or re-fetching it</p> </dd> <dt><a href="#SmartCart.formatMoney">SmartCart.formatMoney</a> ⇒ <code>string</code></dt> <dd> <p>Formats a money amount with the specified format and current cart currency (used to render money amounts in the Smart Cart)</p> </dd> <dt><a href="#SmartCart.getCalculatedCartDiscount">SmartCart.getCalculatedCartDiscount</a> ⇒ <code>number</code></dt> <dd> <p>Gets the calculated discount for the cart, based on detected automatic discounts OR applied discount codes</p> </dd> <dt><a href="#SmartCart.getComponentsByType">SmartCart.getComponentsByType</a> ⇒ <code>Array</code></dt> <dd> <p>Gets all of the Smart Cart components of a specific type from the settings.components array</p> </dd> <dt><a href="#SmartCart.getFirstComponentByType">SmartCart.getFirstComponentByType</a> ⇒ <code>object</code> | <code>undefined</code></dt> <dd> <p>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)</p> </dd> <dt><a href="#SmartCart.getOriginalCartTotal">SmartCart.getOriginalCartTotal</a> ⇒ <code>number</code></dt> <dd> <p>Gets the cart original price (before discounts). Some items are excluded from the subtotal calculation.</p> </dd> <dt><a href="#SmartCart.getVueConfig">SmartCart.getVueConfig</a> ⇒ <code>object</code></dt> <dd> <p>Defines the Smart Cart's Vue configuration object</p> </dd> <dt><a href="#SmartCart.hide">SmartCart.hide</a></dt> <dd> <p>Hides the Smart Cart from the customer, stops any announcement bars, and triggers the Smart Cart hide event</p> </dd> <dt><a href="#SmartCart.init">SmartCart.init</a></dt> <dd> <p>Initializes the Smart Cart</p> </dd> <dt><a href="#SmartCart.isComponentVisible">SmartCart.isComponentVisible</a> ⇒ <code>boolean</code></dt> <dd> <p>Determines whether a Smart Cart component is visible based on its visibility status</p> </dd> <dt><a href="#SmartCart.setCart">SmartCart.setCart</a></dt> <dd> <p>Sets the internal SmartCart.cart object, syncs the cart note (if applicable), and enriches the cart product data</p> </dd> <dt><a href="#SmartCart.shouldUseProductMetafields">SmartCart.shouldUseProductMetafields</a> ⇒ <code>boolean</code></dt> <dd> <p>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)</p> </dd> <dt><a href="#SmartCart.show">SmartCart.show</a></dt> <dd> <p>Shows the Smart Cart to the customer, initializes any announcement bars, and triggers the Smart Cart show event</p> </dd> <dt><a href="#SmartCart.sizeImage">SmartCart.sizeImage</a> ⇒ <code>string</code></dt> <dd> <p>Gets a Shopify image size URL with a specified size</p> </dd> <dt><a href="#SmartCart.updateCartCount">SmartCart.updateCartCount</a></dt> <dd> <p>Updates the Cart Item Count element with the current item count (if the Item Count selector is defined in the Theme Selectors in settings)</p> </dd> <dt><a href="#SmartCart.updateCartSubtotal">SmartCart.updateCartSubtotal</a></dt> <dd> <p>Updates the Cart Subtotal element with the current subtotal (if the Cart Subtotal selector is defined in the Theme Selectors in settings)</p> </dd> <dt><a href="#SmartCart.updateLiveRegion">SmartCart.updateLiveRegion</a></dt> <dd> <p>Updates the ARIA Live Region in the Smart Cart with a message</p> </dd> <dt><a href="#SmartCart.skip_open">SmartCart.skip_open</a></dt> <dd> <p>Property that can be overridden to prevent the cart from opening on product adds.</p> </dd> </dl> <a name="SmartCart.currency"></a> ## `SmartCart.currency` ⇒ <code>string</code> Gets the current cart currency code **Returns**: <code>string</code> - the currency code for the current Shopify cart object\ <a name="SmartCart.destroy"></a> ## `SmartCart.destroy` Destroys the Smart Cart instance, removes it from the DOM, unbinds events, and resets default properties <a name="SmartCart.discountTotal"></a> ## `SmartCart.discountTotal` ⇒ <code>string</code> Gets the discount total string to display in the Smart Cart **Returns**: <code>string</code> - The total discount amount (formatted) <Table> <thead> <tr> <th> Param </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> format </td> <td> <code>string</code> </td> <td> Money formatting string (ie. `'${{amount}}'`) </td> </tr> </tbody> </Table> <a name="SmartCart.emptyCartMarkup"></a> ## `SmartCart.emptyCartMarkup` ⇒ <code>string</code> Gets the empty cart markup from the settings object **Returns**: <code>string</code> - The empty cart markup\ <a name="SmartCart.enrich"></a> ## `SmartCart.enrich` Enriches the cart product data, either pulling it from local storage or re-fetching it <a name="SmartCart.formatMoney"></a> ## `SmartCart.formatMoney` ⇒ <code>string</code> Formats a money amount with the specified format and current cart currency\ (used to render money amounts in the Smart Cart) **Returns**: <code>string</code> - The formatted money amount <Table> <thead> <tr> <th> Param </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> amount </td> <td> <code>number</code> \| <code>string</code> </td> <td> The money amount to format </td> </tr> <tr> <td> [format] </td> <td> <code>string</code> </td> <td> Money formatting string (ie. `'${{amount}}'`) </td> </tr> <tr> <td> [currencyCode] </td> <td> <code>string</code> </td> <td> The currency code to use for formatting </td> </tr> </tbody> </Table> <a name="SmartCart.getCalculatedCartDiscount"></a> ## `SmartCart.getCalculatedCartDiscount` ⇒ <code>number</code> Gets the calculated discount for the cart, based on detected automatic discounts OR applied discount codes **Returns**: <code>number</code> - The total discount amount for the cart\ <a name="SmartCart.getComponentsByType"></a> ## `SmartCart.getComponentsByType` ⇒ <code>Array</code> Gets all of the Smart Cart components of a specific type from the settings.components array **Returns**: <code>Array</code> - An array of Smart Cart components of the specified type <Table> <thead> <tr> <th> Param </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> type </td> <td> <code>string</code> </td> <td> The component type to filter by </td> </tr> </tbody> </Table> <a name="SmartCart.getFirstComponentByType"></a> ## `SmartCart.getFirstComponentByType` ⇒ <code>object</code> \| <code>undefined</code> 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**: <code>object</code> \| <code>undefined</code> - The first Smart Cart component of the specified type <Table> <thead> <tr> <th> Param </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> type </td> <td> <code>string</code> </td> <td> The component type to filter by </td> </tr> </tbody> </Table> <a name="SmartCart.getOriginalCartTotal"></a> ## `SmartCart.getOriginalCartTotal` ⇒ <code>number</code> Gets the cart original price (before discounts). Some items are excluded from the subtotal calculation. **Returns**: <code>number</code> - The original price of the cart (included items original prices combined)\ <a name="SmartCart.getVueConfig"></a> ## `SmartCart.getVueConfig` ⇒ <code>object</code> Defines the Smart Cart's Vue configuration object **Returns**: <code>object</code> - Vue configuration object\ <a name="SmartCart.hide"></a> ## `SmartCart.hide` Hides the Smart Cart from the customer, stops any announcement bars, and triggers the Smart Cart hide event <Table> <thead> <tr> <th> Param </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> e </td> <td> <code>event</code> </td> <td> The event object (if applicable) </td> </tr> </tbody> </Table> <a name="SmartCart.init"></a> ## `SmartCart.init` Initializes the Smart Cart <Table> <thead> <tr> <th> Param </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> settings </td> <td> <code>object</code> </td> <td> The Smart Cart settings object </td> </tr> </tbody> </Table> <a name="SmartCart.isComponentVisible"></a> ## `SmartCart.isComponentVisible` ⇒ <code>boolean</code> Determines whether a Smart Cart component is visible based on its visibility status **Returns**: <code>boolean</code> - Whether the component is visible <Table> <thead> <tr> <th> Param </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> component </td> <td> <code>object</code> </td> <td> A Smart Cart component object from the settings.components array </td> </tr> </tbody> </Table> <a name="SmartCart.setCart"></a> ## `SmartCart.setCart` Sets the internal SmartCart.cart object, syncs the cart note (if applicable), and enriches the cart product data <Table> <thead> <tr> <th> Param </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> cart </td> <td> <code>object</code> </td> <td> The Shopify cart object to set as the Smart Cart cart </td> </tr> </tbody> </Table> <a name="SmartCart.shouldUseProductMetafields"></a> ## `SmartCart.shouldUseProductMetafields` ⇒ <code>boolean</code> 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**: <code>boolean</code> - Whether the setting is enabled\ <a name="SmartCart.show"></a> ## `SmartCart.show` Shows the Smart Cart to the customer, initializes any announcement bars, and triggers the Smart Cart show event <Table> <thead> <tr> <th> Param </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> e </td> <td> <code>event</code> </td> <td> The event object (if applicable) </td> </tr> </tbody> </Table> <a name="SmartCart.sizeImage"></a> ## `SmartCart.sizeImage` ⇒ <code>string</code> Gets a Shopify image size URL with a specified size **Returns**: <code>string</code> - The new image URL with the specified size <Table> <thead> <tr> <th> Param </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> src </td> <td> <code>string</code> </td> <td> The original image URL </td> </tr> <tr> <td> size </td> <td> <code>string</code> </td> <td> The desired image size (ie. 'small', 'medium', 'large') </td> </tr> </tbody> </Table> <a name="SmartCart.updateCartCount"></a> ## `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) <a name="SmartCart.updateCartSubtotal"></a> ## `SmartCart.updateCartSubtotal` Updates the Cart Subtotal element with the current subtotal\ (if the Cart Subtotal selector is defined in the Theme Selectors in settings) <a name="SmartCart.updateLiveRegion"></a> ## `SmartCart.updateLiveRegion` Updates the ARIA Live Region in the Smart Cart with a message <Table> <thead> <tr> <th> Param </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> message </td> <td> <code>string</code> </td> <td> The message to display in the live region </td> </tr> </tbody> </Table> <a name="SmartCart.skip_open"></a> ## `SmartCart.skip_open` When this property is set to **true**, it will prevent Smart Cart from opening when an item is added to cart (clicking on cart icon will still allow the Smart Cart to open, however). ```javascript title="Rebuy.SmartCart.skip_open = true;" ```