Documentation
Feedback
Guides
VTEX IO Apps

VTEX IO Apps
Buy Button
vtex.store-components
Version: 3.151.2
Latest version: 3.178.2

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

{"base64":"  ","img":{"width":73,"height":20,"type":"svg","mime":"image/svg+xml","wUnits":"px","hUnits":"px","url":"https://img.shields.io/badge/-Deprecated-red"}}

:warning: The Buy Button block has been deprecated in favor of the Add To Cart Button app. Although support for this block is still granted, we strongly recommend you to update your store theme with the Add to Cart Button's blocks in order to keep up with the component's evolution.

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

The buy-button block allows users to add products in the Minicart (minicart.v1).

:warning: The Buy Button block only effectively function i.e. only adds products to the Minicart if the store uses the Minicart v1. When using the Minicart v2, use the Add To Cart Button instead.

{"base64":"  ","img":{"width":2094,"height":1052,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":407330,"url":"https://user-images.githubusercontent.com/284515/70233985-69e13700-173e-11ea-91f7-6675a6a0e73b.png"}}

Configuration

  1. Import the vtex.store-component app to your theme's dependencies in the manifest.json;

_10
"dependencies": {
_10
+ "vtex.store-components": "3.x"
_10
}

  1. Add the buy-button to other theme block using the product context, such as the product-summary.shelf. In the example below, the buy-button is added to the flex-layout.row block from the store.product template (which uses the product context):

_16
"store.product": {
_16
"children": [
_16
"flex-layout.row#product",
_16
]
_16
},
_16
"flex-layout.row#product": {
_16
"children": [
_16
"buy-button#product"
_16
]
_16
},
_16
"buy-button#product": {
_16
"props": {
_16
"isOneClickBuy": true,
_16
"showTooltipOnSkuNotSelected": false
_16
}
_16
},

Prop nameTypeDescriptionDefault value
isOneClickBuybooleanWhether the user should be redirected to the checkout page (true) or not (false) when the Add To Cart Button is clicked on.false
customToastURLstringDefines the link to where users will be redirected when the Buy Button is clicked on and the isOneClickBuy prop is set to true./checkout/#/cart
shouldOpenMinicartbooleanWhether the Minicart should be opened when the Buy Button is clicked on (true) or not (false).false
largebooleanWhether the Buy Button should fill its whole width (true) or not (false).false
availablebooleanWhether the Buy Button block is available for using (true) or not (false).true
showToastbooleanWhether a Toast (pop-up notification) should be displayed when adding an item to the minicart (true) or not (false)false
showItemsPricebooleanWhether the total price of items added to the cart should be displayed (true) or not (false).false
shouldAddToCartbooleanWhether the Buy Button should add products to the minicart when clicked on (true) or not (false).true
showTooltipOnSkuNotSelectedbooleanWhether a tooltip should be displayed when the Buy Button is clicked on with no SKU was selected (true) or not (false).true

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
buyButtonText
buttonDataContainer
buttonItemsPrice
See also
Vtex.store Components
VTEX IO Apps
VTEX App Store
VTEX IO Apps