I have added products on the homepage using the widget, how to enable ajax for add-to-cart button and wishlist button of product widgets.
Hi @Aveeva,
You have to override addtocart.phtml file
app/design/frontend/vendorname/themename/Magento_Catalog/templates/product/view/addtocart.phtml
Now just replace "bindSubmit": false to "bindSubmit": true
<script type="text/x-magento-init">
{
"#product_addtocart_form": {
"catalogAddToCart": {
"bindSubmit": false
}
}
}
</script>to
<script type="text/x-magento-init">
{
"#product_addtocart_form": {
"catalogAddToCart": {
"bindSubmit": true
}
}
}
</script>Now delete cache and page_cache folder or flush cache.
Note: Make sure you have to set No from Store -> Configuration -> Sales -> Checkout-> Shopping Cart -> After Adding a Product Redirect to Shopping Cart to No.
Hope this can help you! Let me know if you need further assistance.
________
If issue solved, Click Kudos & Accept as Solution.