Home > widget-integration > CartModule
CartModule class
Cart module managing cart functionality via Widget Integration framework
This module orchestrates cart operations including: - Cart modal display and interactions - Add to cart functionality - Cart state management - Theme-specific cart icon handling
Technical Support teams can extend this module for shop-specific customization: - Override block listener setup via - Customize block initialization via - Add custom error handling via
Signature:
export declare class CartModule
Example
// Extend CartModule for custom initialization
window.boostWidgetIntegration.extend('CartModule', (CartModule) => {
return class CustomCartModule extends CartModule {
setupBlockListener() {
super.setupBlockListener();
// Add custom cart event handling
this.registerCustomEventHandlers();
}
async onInitBlock(block) {
// Add shop-specific tracking before initialization
this.trackCartBlockInit(block.id);
await super.onInitBlock(block);
}
registerCustomEventHandlers() {
window.addEventListener('custom-cart-event', () => {
this.controller?.openCart();
});
}
trackCartBlockInit(blockId) {
window.dataLayer?.push({
event: 'cart_block_initialized',
blockId
});
}
};
});
Constructors
|
Constructor |
Modifiers |
Description |
|---|---|---|
|
Constructs a new instance of the |
Properties
|
Property |
Modifiers |
Type |
Description |
|---|---|---|---|
|
|
AppService | ||
|
CartController | null | |||
|
|
ModuleRefImpl |
Methods
|
Method |
Modifiers |
Description |
|---|---|---|
|
|
Handles errors that occur during cart block initialization. Override this method to customize error handling, add custom logging, or provide user feedback. | |
|
|
Called when a cart block is initialized. Override this method to customize cart initialization or add shop-specific setup logic. | |
|
|
Sets up the TAE App block listener for cart blocks. Override this method to customize block registration logic or support additional block types. |