Skip to content

Subtotal Methods

SmartCart.getSubtotalSettingsobject

Returns the subtotal settings from the SmartCart components array.

SmartCart.subtotalstring

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

Param Type Description
format string Currency format string

Example

// Get the formatted subtotal for display
const subtotal = SmartCart.subtotal('${{amount}}');
console.log('Cart subtotal:', subtotal); // "$49.99"

// Display in a custom element
document.querySelector('.my-subtotal').innerHTML = subtotal;

SmartCart.subtotalLabelstring

Returns the subtotal label.

Example

// Get the configured subtotal label
const label = SmartCart.subtotalLabel();
console.log(label); // "Subtotal" or custom label from settings

SmartCart.subtotalNumbernumber

Returns the subtotal number (rather than a formatted string). This is useful for calculating the subtotal for other components.

Example

// Get the raw subtotal value for calculations
const subtotal = SmartCart.subtotalNumber();
console.log('Subtotal in cents:', subtotal); // 4999

// Check if cart meets a minimum threshold (e.g., $50 = 5000 cents)
if (subtotal >= 5000) {
  console.log('Eligible for free shipping!');
}
See something that needs updating? Suggest an edit