📢 Use this project, contribute to it or open issues to help evolve it using Store Discussion.
The buy-button
block allows users to add products in the Minicart (minicart.v1
).
- Import the
vtex.store-component
app to your theme's dependencies in themanifest.json
;
"dependencies": {
+ "vtex.store-components": "3.x"
}
- Add the
buy-button
to other theme block using the product context, such as theproduct-summary.shelf
. In the example below, thebuy-button
is added to theflex-layout.row
block from thestore.product
template (which uses the product context):
"store.product": {
"children": [
"flex-layout.row#product",
]
},
"flex-layout.row#product": {
"children": [
"buy-button#product"
]
},
"buy-button#product": {
"props": {
"isOneClickBuy": true,
"showTooltipOnSkuNotSelected": false
}
},
Prop name | Type | Description | Default value |
---|---|---|---|
isOneClickBuy |
boolean |
Whether the user should be redirected to the checkout page (true ) or not (false ) when the Add To Cart Button is clicked on. |
false |
customToastURL |
string |
Defines 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 |
shouldOpenMinicart |
boolean |
Whether the Minicart should be opened when the Buy Button is clicked on (true ) or not (false ). |
false |
large |
boolean |
Whether the Buy Button should fill its whole width (true ) or not (false ). |
false |
available |
boolean |
Whether the Buy Button block is available for using (true ) or not (false ). |
true |
showToast |
boolean |
Whether a Toast (pop-up notification) should be displayed when adding an item to the minicart (true ) or not (false ) |
false |
showItemsPrice |
boolean |
Whether the total price of items added to the cart should be displayed (true ) or not (false ). |
false |
shouldAddToCart |
boolean |
Whether the Buy Button should add products to the minicart when clicked on (true ) or not (false ). |
true |
showTooltipOnSkuNotSelected |
boolean |
Whether a tooltip should be displayed when the Buy Button is clicked on with no SKU was selected (true ) or not (false ). |
true |
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 |
Thanks goes to these wonderful people:
This project follows the all-contributors specification. Contributions of any kind are welcome!