Cross-Sell Widget Methods
SmartCart.getAllCrossSellWidgetIds ⇒ Array.<string>¶
Get all cross sell widget IDs in Cross-Sell components in the current Smart Cart settings
Returns: Array.<string> - Array of widget IDs
Example
// Get all cross-sell widget IDs configured in Smart Cart
const widgetIds = SmartCart.getAllCrossSellWidgetIds();
console.log('Cross-sell widgets:', widgetIds);
// Output: ['widget-123', 'widget-456']
// Use widget IDs to fetch recommendations via the API
widgetIds.forEach(id => {
console.log(`Widget ${id} is configured`);
});
SmartCart.getWidgetIdByComponentId ⇒ string | null¶
Get the widget ID by component ID
Returns: string | null - The widget ID
| Param | Type | Description |
|---|---|---|
| componentId | string |
The component ID |
Example
// Get the widget ID for a specific Smart Cart component
const widgetId = SmartCart.getWidgetIdByComponentId('cross-sell-component-1');
if (widgetId) {
console.log('Found widget:', widgetId);
} else {
console.log('No widget found for this component');
}
SmartCart.hasCrossSellWidgets ⇒ boolean¶
Check if there are cross sell widgets in the current Smart Cart settings
Returns: boolean - True if there are cross sell widgets
Example
// Check if cross-sell widgets are configured before showing related UI
if (SmartCart.hasCrossSellWidgets()) {
console.log('Cross-sell recommendations are enabled');
} else {
console.log('No cross-sell widgets configured');
}
See something that needs updating?
Suggest an edit