Changing "Add to cart" button text in Magento 2.1.0 ( Overriding js file )
You have to override js file from path
vendor/magento/module-catalog/view/frontend/web/js/catalog-add-to-cart.js
To
app/design/frontend/YourTheme/Packadge/Magento_Catalog/web/js/catalog-add-to-cart.js
You have to changes text which you want to from this file.
Let me know if you have any query.
you need to override, catalog-add-to-cart.js from path,
vendor/magento/module-catalog/view/frontend/web/js
Text is changing from here after ajax call. you can change text here.
The text changed by Javascript after Ajax call. We can take a look:
vendor/magento/module-catalog/view/frontend/web/js/catalog-add-to-cart.js
For the best practice, should use mixins
for "overriding":
We can create a module, and then add these files:
app/code/Vendor/Module/view/frontend/requirejs-config.js
var config = {
config: {
mixins: {
'Magento_Catalog/js/catalog-add-to-cart': {
'Vendor_Module/js/catalog-add-to-cart-mixin': true
}
}
}
};
app/code/Vendor/Module/view/frontend/web/js/catalog-add-to-cart-mixin.js
define([
'jquery',
'mage/translate',
'jquery/ui'
],
function ($, $t) {
'use strict';
return function (target) {
$.widget('mage.catalogAddToCart', target, {
options: {
addToCartButtonTextWhileAdding: $t('Adding Testing...'),
addToCartButtonTextAdded: $t('Added Testing'),
addToCartButtonTextDefault: $t('Add to Cart Testing')
}
});
return $.mage.catalogAddToCart;
};
});