How to add ajax to custom theme add-to-cart and Wishlist button?
-
15-04-2021 - |
Question
I created my website using a custom theme, how to implement ajax to my add-to-cart and wishlist button?
I tried the following step, it not working,
vendor\magento\module-catalog\view\frontend\templates\product\view\addtocart.phtml (For testing purpose added in core files)
<script type="text/x-magento-init">
{
"#product_addtocart_form": {
"Magento_Catalog/js/validate-product": {},
"catalogAddToCart": {
"bindSubmit": true
}
}
}
</script>
La solution
@zus I would suggest to review the below post where you can get your question answer easily. Here you will find an extension option as well as a customization option. But I would suggest to go with the extension option.
Magento 2 : Add to compare and add to wishlist with ajax
https://www.tigren.com/magento-2-extensions/ajax-suite-magento-2/
Please let me know if this will not help.
Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange