HomeWiki
HomeWiki
  1. Components
  • Back to home
  • 1. Themes
  • Layout
    • New Layout
    • Legacy Layout
  • Components
    • Announcement
    • Banner Carousel
    • Banner With Products Carousel
    • Blog Category List
    • Blog List
    • Brand List
    • Brands Carousel
    • Breadcrumb
    • Call To Action
    • Cart
    • Categories List
    • Change Password
    • Checkout
    • Cookie Manager
    • Filter list
    • Footer
    • Forgot Password
    • Form
    • Hero Carousel
    • Icon Block
    • Invitation
    • Last Visited Products
    • Layout
    • Login
    • Map
    • Nav Bar
    • Offer
    • Product Attachments
    • Product Attributes
    • Product Documentation
    • Product Expected
    • Product Modal
    • Products Block
    • Products Carousel
    • Product Single
    • Profile
    • Quote
    • Register
    • Related Products
    • Search
    • Stores
    • Subscribe Newsletter
    • Text with Image
    • Top Bar
    • Video
  • Reusables
    • Getting Started
  • Assets
    • Getting Started
  • SDK
    • Products
      • _findProductsByCategory
      • _findProductsByIds
      • _findProductsByTitle
      • _findProductsByFilter
      • _findProductsByCriteria
      • _findProductsAndCalculate
      • _findProductsThenCalculate
      • _getProductAttributeSet
      • _setLastVisited
    • Categories
      • _findCategoryTreeById
      • _findCategoriesByIds
      • _findCategoryByAlias
      • _findCategoryTreeByAlias
      • _getCategoryContent
    • Collections
      • _getCollectionContent
      • _findCollectionsByIds
      • _findCollectionsByIdsThenCalculate
    • Brands
      • _getBrandContent
      • _findBrandsByIds
    • Cart
      • _addToCartMulti
      • _addToCart
      • _setCart
      • _clearCart
      • _setCartListener
      • _removeFromCart
      • _calculateCart
    • Checkout
      • _startCheckout
      • _updateCheckout
      • _completeCheckout
    • Shopping Lists
      • _getShoppingLists
      • _updateShoppingList
      • _createShoppingList
      • _deleteShoppingList
      • _getShoppingListByAlias
    • Navigation
      • _getFooterMenu
      • _getHeaderMenu
    • Users
      • _getUserById
    • Utils
      • _calculateCurrency
      • _getCurrencySymbol
      • _getCulture
      • _subscribeToNewsletter
      • _findUnitsByIds
  • Vs Code
    • Getting Started
  1. Components

Cart

Cart Component Documentation#

Overview#

The Cart Component is a component designed to manage the cart functionality within an e-commerce application. It handles cart item display, quantity updates, subtotal calculations, and checkout initiation. It also provides quick access to product search and handles scenarios where the cart is empty.

Model Documentation#

Model Structure#

The model passed to the Cart Component is expected to have the following structure:
{
    "id": "string",
    "cssClass": "string",
    "items": [
        {
            "id": "string",
            "title": "string",
            "imageLink": "string",
            "price": "number",
            "quantity": "number",
            "sku": "string",
            "link": "string"
        }
    ],
    "isAuthenticated": "boolean"
}

Example Model#

{
    "id": "cartComponent",
    "cssClass": "cart-container",
    "items": [
        {
            "id": "1",
            "title": "Product 1",
            "imageLink": "/images/product1.jpg",
            "price": 100,
            "quantity": 2,
            "sku": "SKU1234",
            "link": "/product/1"
        },
        {
            "id": "2",
            "title": "Product 2",
            "imageLink": "/images/product2.jpg",
            "price": 200,
            "quantity": 1,
            "sku": "SKU5678",
            "link": "/product/2"
        }
    ],
    "isAuthenticated": true
}

Component Structure#

The Cart Component is structured using Vue.js. The component listens for changes in the cart state, updates quantities, and manages the checkout process.

HTML Template#

JavaScript#

Explanation#

HTML Template: The template consists of different sections that display the cart items, a summary of the order, and error modals. It dynamically loads the content based on the cart's state (loading, empty, or filled with items).
JavaScript: The script handles cart operations such as updating quantities, removing items, and proceeding to checkout. It also listens for cart updates and recalculates the cart data.
Previous
Call To Action
Next
Categories List
Built with