I override magento\vendor\magento\module-catalog\view\frontend\web\js\catalog-add-to-cart.js
as I need to change the text from "Add to Cart" to "Buy Now"
magento\app\code\Custom\Module\view\frontend\requirejs-config.js
var config = {
"map": {
"*": {
"Magento_Catalog/js/catalog-add-to-cart": "Custom_Module/js/catalog-add-to-cart"
}
}
};
It works fine on Product Page, but on Category page it still goes to Main File not override file.
Why?
Best Answer
I had the same issue and I resolved the issue by this code.
1 => In your app\code\Custom\Module\view\frontend\requirejs-config.js
Add following code.
2 => Put your add to cart file in app\code\Custom\Module\view\frontend\web\js path with name catalog-add-to-cart.js
Now you can copy paste the parent file code in the overridden file and make your changes.
Above code will override the file and also replace the parent file