Documentation
Feedback
Guides
VTEX IO Apps

VTEX IO Apps
Basic components
Minicart
Official extension
Version: 2.60.0
Latest version: 2.67.1

This page is about version 2.60.0 of the app, which is not the most recent version. The latest stable version is 2.67.1.

{"base64":"  ","img":{"width":110,"height":20,"type":"svg","mime":"image/svg+xml","wUnits":"px","hUnits":"px","url":"https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square"}}

:information_source: 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.

{"base64":"  ","img":{"width":2880,"height":1575,"type":"gif","mime":"image/gif","wUnits":"px","hUnits":"px","length":1703446,"url":"https://user-images.githubusercontent.com/52087100/73321194-7f477e80-4220-11ea-844b-f24d1c10363c.gif"}}

Configuration

  1. Import the Minicart app to your theme's dependencies in the manifest.json as shown below:

_10
"dependencies": {
_10
"vtex.minicart": "2.x"
_10
}

  1. Add the minicart.v2 block to your header. For example:

_13
"header.full": {
_13
"blocks": ["header-layout.desktop", "header-layout.mobile"]
_13
},
_13
_13
"header-layout.desktop": {
_13
"children": [
_13
"header-row#1-desktop",
_13
]
_13
},
_13
_13
"header-row#1-desktop": {
_13
"children": ["minicart.v2"],
_13
},

:warning: 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. 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. Possible values are: rightToLeft or leftToRight).rightToLeft
linkVariationUrlstringLink associated to the link Minicart.undefined
maxDrawerWidthnumberMaximum width (in pixels) for the drawer Minicart when opened.440
openOnHoverbooleanWhether the popup minicart should open when the user hovers over it.false
quantityDisplayenumShows the quantity badge even when the amount of products in the cart is zero. Possible values are: always or not-empty or never).not-empty
itemCountModeenumQuantity badge behavior when displaying the number of total items added in Minicart. Possible values are: total (quantity badge displays the number of items added to the cart), distinct (only displays the number of different products added to the cart), totalAvailable (displays the number of available items added to the cart), and distinctAvailable (displays the number of different and available products added to the cart).distinct
backdropModeenumControls whether the backdrop should be displayed when the drawer Minicart is opened or not. Possible values are: visible (rendering the backdrop) or none (rendering the drawer without backdrop).none
MinicartIconblockIcon displayed in the Minicart button. This prop's value must match the name of the block responsible for rendering the desired icon.icon-cart (from Store Icons app)
customPixelEventIdstringStore event ID responsible for triggering the minicart.v2 to automatically open itself on the interface.undefined
customPixelEventNamestringStore event name responsible for triggering the minicart.v2 to automatically open itself on the interface. Some examples are: 'addToCart' and 'removeFromCart'. Notice that using this prop will make the minicart.v2 open in every event with the specified name if no customPixelEventId is specified.undefined
classesCustomCSSClassesUsed to override default CSS handles. To better understand how this prop works, we recommend reading about it here. Note that this is only useful if you're importing this block as a React component.undefined

Advanced Configuration

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


_77
// This is the default blocks implementation for the minicart-layout
_77
{
_77
"minicart.v2": {
_77
"props": {
_77
"MinicartIcon": "icon-cart#minicart-icon"
_77
},
_77
"children": ["minicart-base-content"]
_77
},
_77
"icon-cart#minicart-icon": {
_77
"props": {
_77
"size": 24
_77
}
_77
},
_77
"minicart-base-content": {
_77
"blocks": ["minicart-empty-state"],
_77
"children": ["minicart-product-list", "flex-layout.row#minicart-footer"]
_77
},
_77
"flex-layout.row#minicart-footer": {
_77
"props": {
_77
"blockClass": "minicart-footer"
_77
},
_77
"children": ["flex-layout.col#minicart-footer"]
_77
},
_77
"flex-layout.col#minicart-footer": {
_77
"children": ["minicart-summary", "minicart-checkout-button"]
_77
},
_77
"minicart-product-list": {
_77
"blocks": ["product-list#minicart"]
_77
},
_77
"product-list#minicart": {
_77
"blocks": ["product-list-content-mobile"]
_77
},
_77
"minicart-summary": {
_77
"blocks": ["checkout-summary.compact#minicart"]
_77
},
_77
_77
"checkout-summary.compact#minicart": {
_77
"children": ["summary-totalizers#minicart"],
_77
"props": {
_77
"totalizersToShow": ["Items", "Discounts"]
_77
}
_77
},
_77
"summary-totalizers#minicart": {
_77
"props": {
_77
"showTotal": true,
_77
"showDeliveryTotal": false
_77
}
_77
},
_77
"minicart-empty-state": {
_77
"children": ["flex-layout.row#empty-state"]
_77
},
_77
"flex-layout.row#empty-state": {
_77
"children": ["flex-layout.col#empty-state"]
_77
},
_77
"flex-layout.col#empty-state": {
_77
"children": [
_77
"icon-cart#minicart-empty-state",
_77
"rich-text#minicart-default-empty-state"
_77
],
_77
"props": {
_77
"horizontalAlign": "center",
_77
"verticalAlign": "middle",
_77
"rowGap": 5
_77
}
_77
},
_77
"icon-cart#minicart-empty-state": {
_77
"props": {
_77
"size": 64,
_77
"blockClass": "minicart-empty-state"
_77
}
_77
},
_77
"rich-text#minicart-default-empty-state": {
_77
"props": {
_77
"text": "Your cart is empty."
_77
}
_77
}
_77
}

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 copy the code above and change it as you wish.

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

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
See also
VTEX App Store
VTEX IO Apps