Add to Cart Button
📢 Use this project, contribute to it or open issues to help evolve it using Store Discussion.
Add To Cart Button
The add-to-cart-button
is a block responsible for adding products in the Minicart (minicart.v2
).
⚠️ The Add To Cart Button only effectively function i.e. only adds products to the Minicart if the store uses the Minicart v2. In this scenario, it successfully works in the Shelf component as well as in the Product Details page. When using the Minicart v1, you should configure the Buy Button block in the Product Details page, and the Product Summary Buy Button in the Shelf component instead.
Configuration
Import the
vtex.add-to-cart-button
app to your theme's dependencies in the manifest.json, for example:
Add the
add-to-cart-button
to other theme block using the product context, such as theproduct-summary.shelf
. In the example below, theadd-to-cart-button
is added to theflex-layout.row
block from thestore.product
template (which uses the product context):
Prop name | Type | Description | Default value |
---|---|---|---|
|
| Controls what happens when users click on the button. Possible values are: |
|
|
| Controls whether the 'onClick' event (triggered upon user clicks) should be spread to the page's parent elements. Possible values are: |
|
|
| Whether the user should be redirected to the checkout page ( |
|
|
| Defines the link to where users will be redirected when the Add To Cart Button is clicked on and the |
|
|
| Defines the link to where users will be redirected when the Toast (pop-up notification displayed when adding an item to the minicart) is clicked on. |
|
|
| Defines a custom text message to be displayed on the Add To Cart Button. |
|
|
| Defines a custom text message to be displayed on the Add To Cart Button when a product is unavailable. |
|
|
| Define the |
|
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 |
---|
|
|
|
Contributors ✨
Thanks goes to these wonderful people:
This project follows the all-contributors specification. Contributions of any kind are welcome!
Last updated