ThemeComponent & BaseComponent
ThemeComponent (and ThemeReactComponent)
ThemeComponent is the class that all of your commponents extend. If you have any functions that would be useful to have access to in every function that you don't have a more appropriate place for (i.e. formatting), you can add them to ThemeComponent.
ThemeReactComponent is the equivalent for your theme's react components.
BaseComponent
BaseComponent is the class in SALVO-TS that ThemeComponent and components extend. This is the class that implements the Web Component lifecycle, instance helper functions, and many other features.
Session state
obsolete
You can access details about the customer's current session directly through your component.Cart state
obsolete
this.cart returns the current Cart object, which lets you query and update the customer's cart.
typescript// Access itemslet items = this.cart.items;// Add itemsawait this.cart.addItems([{id: 123456789, quantity: 3}},{id: 123456789, quantity: 1, attributes: {_gift_message: 'Enjoy!'}},]);// Helpful utility functionslet purchasedAccessory = this.cart.queryItems({tag: 'Accessory'}).length > 0;await this.cart.clear({refreshPage: false})
typescript// Access itemslet items = this.cart.items;// Add itemsawait this.cart.addItems([{id: 123456789, quantity: 3}},{id: 123456789, quantity: 1, attributes: {_gift_message: 'Enjoy!'}},]);// Helpful utility functionslet purchasedAccessory = this.cart.queryItems({tag: 'Accessory'}).length > 0;await this.cart.clear({refreshPage: false})
See working with the cart for more info.