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

(constructor)(moduleRef, appService)

Constructs a new instance of the CartModule class

Properties

Property

Modifiers

Type

Description

appService

protected

AppService

controller

CartController | null

moduleRef

protected

ModuleRefImpl

Methods

Method

Modifiers

Description

handleBlockInitError(error, block)

protected

Handles errors that occur during cart block initialization. Override this method to customize error handling, add custom logging, or provide user feedback.

onInitBlock(block)

protected

Called when a cart block is initialized. Override this method to customize cart initialization or add shop-specific setup logic.

setupBlockListener()

protected

Sets up the TAE App block listener for cart blocks. Override this method to customize block registration logic or support additional block types.