📢 Use this project, contribute to it or open issues to help evolve it using Store Discussion.

Minicart

All Contributors

ℹ️ Minicart v1 block has been deprecated in favor of Minicart v2 which can be customized using the blocks defined by Product List and Checkout Summary. If you’re still using the former version, you can find its documentation here: Minicart v1 documentation

The VTEX Minicart is a block that displays a summary list of all items added by customers in their shopping cart. Its data is fetched from the Checkout OrderForm API.

minicart-v2-gif

Configuration

  1. Import the Minicart app to your theme's dependencies in the manifest.json as shown below:
"dependencies": {
  "vtex.minicart": "2.x"
}
  1. Add the minicart.v2 block to your header. For example:
"header.full": {
   "blocks": ["header-layout.desktop", "header-layout.mobile"]
 },

 "header-layout.desktop": {
   "children": [
     "header-row#1-desktop",
   ]
 },

 "header-row#1-desktop": {
   "children": ["minicart.v2"],
 },

⚠️ The Minicart v2 will only effectively function if the store uses the Add To Cart Button instead of the Buy Button in blocks such as the Shelf and the Product Details Page. This is because Minicart v2 was built based on an indirect dependency with the Add To Cart button. That means that any other shopping buttons, as the Buy Button, are unable to render Minicart v2, even if it was correctly configured in the code. `

Prop nameTypeDescriptionDefault value
variationEnumMinicart behavior when rendered. The possible values are: 'popup' (it pops up on the Homepage in a minitab window) , 'drawer' (it is rendered through a side bar) or 'link' (when clicked on, it redirects the user to the Checkout page)'drawer'
drawerSlideDirectionEnumSlide direction for the 'drawer' Minicart opening. (values: 'rightToLeft' or 'leftToRight')rightToLeft
linkVariationUrlStringLink associated to the 'link' Minicart.
maxDrawerWidthNumberMaximum width (in pixels) for the 'sidebar' Minicart when opened.440
openOnHoverBooleanWhether the 'popup' minicart should open when the user hovers over itfalse

Advanced Configuration

According to the minicart.v2 composition, it can be highly customizable using other blocks. Currently, its default implementation is as follows:

// This is the default blocks implementation for the minicart-layout
{
  "minicart.v2": {
    "children": ["minicart-base-content"]
  },
  "minicart-base-content": {
    "blocks": ["minicart-empty-state"],
    "children": ["minicart-product-list", "flex-layout.row#minicart-footer"]
  },
  "flex-layout.row#minicart-footer": {
    "props": {
      "blockClass": "minicart-footer"
    },
    "children": ["flex-layout.col#minicart-footer"]
  },
  "flex-layout.col#minicart-footer": {
    "children": ["minicart-summary", "minicart-checkout-button"]
  },
  "minicart-product-list": {
    "blocks": ["product-list#minicart"]
  },
  "product-list#minicart": {
    "blocks": ["product-list-content-mobile"]
  },
  "minicart-summary": {
    "blocks": ["checkout-summary.compact#minicart"]
  },

  "checkout-summary.compact#minicart": {
    "children": ["summary-totalizers#minicart"],
    "props": {
      "totalizersToShow": ["Items", "Discounts"]
    }
  },
  "summary-totalizers#minicart": {
    "props": {
      "showTotal": true,
      "showDeliveryTotal": false
    }
  },
  "minicart-empty-state": {
    "children": ["flex-layout.row#empty-state"]
  },
  "flex-layout.row#empty-state": {
    "children": ["flex-layout.col#empty-state"]
  },
  "flex-layout.col#empty-state": {
    "children": ["rich-text#empty-state"]
  },
  "rich-text#empty-state": {
    "props": {
      "text": "Your cart is empty!"
    }
  }
}

By default implementation we mean that whenever you use minicart.v2 in your store you're actually using the json above behind the scenes.

Therefore, in order to customize the Minicart configuration, you can simply use the default implementation in your code and change it as you wish.

For further information on how to configure each of the blocks used to compose minicart.v2, check out VTEX Checkout Summary and VTEX Product List.

Customization

In order to apply CSS customizations in this and other blocks, follow the instructions given in the recipe on Using CSS Handles for store customization.

CSS Handles
arrowUp
minicartCheckoutButton
minicartContainer
minicartContentContainer
minicartFooter
minicartIconContainer
minicartProductListContainer
minicartQuantityBadge
minicartSideBarContentWrapper
minicartTitle
minicartWrapperContainer
popupChildrenContainer
popupContentContainer
popupWrapper

Contributors

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!