Changing “Add to cart” button text in Magento 2.1.0 ( Overriding js file )Replace add to cart buttonMagento 2 - Extend catalogAddToCart widgetCustom language module not workingChange “add to cart” button to “BUY NOW”Enable / Disable Add to Cart button programmaticallyMagento 2: Skipping Shopping Cart Page after Add to Cartadd class in button after product add to cartMagento 2 : Minicart always showing loader after product add to cart?Magento 2 - Update quantity and totals of cart page without page reload?Magento 2 : Add Block After Add To Cart ButtonAdditional Add to Cart ButtonCan't validate Post Code on checkout pageAdd to cart button is not working properly in listing page in Magento 2

Are there any normal animals in Pokemon universe?

How can I end combat quickly when the outcome is inevitable?

Why did Intel abandon unified CPU cache?

What aircraft was used as Air Force One for the flight between Southampton and Shannon?

Electricity free spaceship

Ability To Change Root User Password (Vulnerability?)

How can I remove material from this wood beam?

Discarding ox heart fat

Proving that a Russian cryptographic standard is too structured

Does Assassinate grant two attacks?

Is it possible to have 2 different but equal size real number sets that have the same mean and standard deviation?

Printing Pascal’s triangle for n number of rows in Python

Advantages of the Exponential Family: why should we study it and use it?

Which is the better way to call a method that is only available to one class that implements an interface but not the other one?

How to hide rifle during medieval town entrance inspection?

What is exactly Avijja -- and how to uproot it?

Cardinal exponentiations inequality

Can a human be transformed into a Mind Flayer?

Why does ''cat "$1:-/dev/stdin | ... &>/dev/null'' work in bash but not dash?

Explain the ending of Black Mirror's "Smithereens"

A word that means "blending into a community too much"

Teaching a class likely meant to inflate the GPA of student athletes

Why am I getting a strange double quote (“) in Open Office instead of the ordinary one (")?

Why Does Mama Coco Look Old After Going to the Other World?



Changing “Add to cart” button text in Magento 2.1.0 ( Overriding js file )


Replace add to cart buttonMagento 2 - Extend catalogAddToCart widgetCustom language module not workingChange “add to cart” button to “BUY NOW”Enable / Disable Add to Cart button programmaticallyMagento 2: Skipping Shopping Cart Page after Add to Cartadd class in button after product add to cartMagento 2 : Minicart always showing loader after product add to cart?Magento 2 - Update quantity and totals of cart page without page reload?Magento 2 : Add Block After Add To Cart ButtonAdditional Add to Cart ButtonCan't validate Post Code on checkout pageAdd to cart button is not working properly in listing page in Magento 2






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








12


















I have changed "Add to cart" text to "I want this" by overriding "vendormagentomodule-catalogviewfrontendtemplatesproductlist.phtml".

But, when I click on "I want this" (i.e. "Add to cart" ) button, the product is added to the cart and then again "Add to cart" text appears on the button.



I think product is added via ajax call, that is why a newly added text is not displaying after the ajax call and "Add to cart" text is displaying.



I have tried this :



I have created a custom extension Ved_Mymodule.



I have checked that extension is active.



After that I followed these steps:



app/code/Ved/Mymodule/view/frontend/requirejs-config.js:



var config = 
map:
'*':
catalogAddToCart:'Ved_Mymodule/js/customCatalogAddToCart'


;


app/code/Ved/Mymodule/view/frontend/web/js/customCatalogAddToCart.js:



define([
'jquery',
'mage/translate',
'jquery/ui'
], function($, $t)
"use strict";

$.widget('Ved_Mymodule.customCatalogAddToCart',$.mage.catalogAddToCart,

//Override function
disableAddToCartButton: function(form) $t('Adding...');
var addToCartButton = $(form).find(this.options.addToCartButtonSelector);
addToCartButton.addClass(this.options.addToCartButtonDisabledClass);
addToCartButton.find('span').text(addToCartButtonTextWhileAdding);
addToCartButton.attr('title', addToCartButtonTextWhileAdding);
console.log('Hello 1');
,

enableAddToCartButton: function(form)
var addToCartButtonTextAdded = this.options.addToCartButtonTextAdded

);

return $.Ved_Mymodule.customCatalogAddToCart;
);


I am trying to print dummy messages in the console.



After this:
I have run static content deploy.
Reindex the data.
Cache cleaned and flushed.



But changes are not appearing.










share|improve this question
























  • Please rename requirejs-config.js and correct the location app/code/Ved/Mymodule/view/frontend/requirejs-config.js.

    – Khoa TruongDinh
    Jul 26 '16 at 9:37












  • Changes are made as you said but still no success. But if I override via theme then it is working.

    – vedu
    Jul 26 '16 at 10:25


















12


















I have changed "Add to cart" text to "I want this" by overriding "vendormagentomodule-catalogviewfrontendtemplatesproductlist.phtml".

But, when I click on "I want this" (i.e. "Add to cart" ) button, the product is added to the cart and then again "Add to cart" text appears on the button.



I think product is added via ajax call, that is why a newly added text is not displaying after the ajax call and "Add to cart" text is displaying.



I have tried this :



I have created a custom extension Ved_Mymodule.



I have checked that extension is active.



After that I followed these steps:



app/code/Ved/Mymodule/view/frontend/requirejs-config.js:



var config = 
map:
'*':
catalogAddToCart:'Ved_Mymodule/js/customCatalogAddToCart'


;


app/code/Ved/Mymodule/view/frontend/web/js/customCatalogAddToCart.js:



define([
'jquery',
'mage/translate',
'jquery/ui'
], function($, $t)
"use strict";

$.widget('Ved_Mymodule.customCatalogAddToCart',$.mage.catalogAddToCart,

//Override function
disableAddToCartButton: function(form) $t('Adding...');
var addToCartButton = $(form).find(this.options.addToCartButtonSelector);
addToCartButton.addClass(this.options.addToCartButtonDisabledClass);
addToCartButton.find('span').text(addToCartButtonTextWhileAdding);
addToCartButton.attr('title', addToCartButtonTextWhileAdding);
console.log('Hello 1');
,

enableAddToCartButton: function(form)
var addToCartButtonTextAdded = this.options.addToCartButtonTextAdded

);

return $.Ved_Mymodule.customCatalogAddToCart;
);


I am trying to print dummy messages in the console.



After this:
I have run static content deploy.
Reindex the data.
Cache cleaned and flushed.



But changes are not appearing.










share|improve this question
























  • Please rename requirejs-config.js and correct the location app/code/Ved/Mymodule/view/frontend/requirejs-config.js.

    – Khoa TruongDinh
    Jul 26 '16 at 9:37












  • Changes are made as you said but still no success. But if I override via theme then it is working.

    – vedu
    Jul 26 '16 at 10:25














12












12








12


2









I have changed "Add to cart" text to "I want this" by overriding "vendormagentomodule-catalogviewfrontendtemplatesproductlist.phtml".

But, when I click on "I want this" (i.e. "Add to cart" ) button, the product is added to the cart and then again "Add to cart" text appears on the button.



I think product is added via ajax call, that is why a newly added text is not displaying after the ajax call and "Add to cart" text is displaying.



I have tried this :



I have created a custom extension Ved_Mymodule.



I have checked that extension is active.



After that I followed these steps:



app/code/Ved/Mymodule/view/frontend/requirejs-config.js:



var config = 
map:
'*':
catalogAddToCart:'Ved_Mymodule/js/customCatalogAddToCart'


;


app/code/Ved/Mymodule/view/frontend/web/js/customCatalogAddToCart.js:



define([
'jquery',
'mage/translate',
'jquery/ui'
], function($, $t)
"use strict";

$.widget('Ved_Mymodule.customCatalogAddToCart',$.mage.catalogAddToCart,

//Override function
disableAddToCartButton: function(form) $t('Adding...');
var addToCartButton = $(form).find(this.options.addToCartButtonSelector);
addToCartButton.addClass(this.options.addToCartButtonDisabledClass);
addToCartButton.find('span').text(addToCartButtonTextWhileAdding);
addToCartButton.attr('title', addToCartButtonTextWhileAdding);
console.log('Hello 1');
,

enableAddToCartButton: function(form)
var addToCartButtonTextAdded = this.options.addToCartButtonTextAdded

);

return $.Ved_Mymodule.customCatalogAddToCart;
);


I am trying to print dummy messages in the console.



After this:
I have run static content deploy.
Reindex the data.
Cache cleaned and flushed.



But changes are not appearing.










share|improve this question



















I have changed "Add to cart" text to "I want this" by overriding "vendormagentomodule-catalogviewfrontendtemplatesproductlist.phtml".

But, when I click on "I want this" (i.e. "Add to cart" ) button, the product is added to the cart and then again "Add to cart" text appears on the button.



I think product is added via ajax call, that is why a newly added text is not displaying after the ajax call and "Add to cart" text is displaying.



I have tried this :



I have created a custom extension Ved_Mymodule.



I have checked that extension is active.



After that I followed these steps:



app/code/Ved/Mymodule/view/frontend/requirejs-config.js:



var config = 
map:
'*':
catalogAddToCart:'Ved_Mymodule/js/customCatalogAddToCart'


;


app/code/Ved/Mymodule/view/frontend/web/js/customCatalogAddToCart.js:



define([
'jquery',
'mage/translate',
'jquery/ui'
], function($, $t)
"use strict";

$.widget('Ved_Mymodule.customCatalogAddToCart',$.mage.catalogAddToCart,

//Override function
disableAddToCartButton: function(form) $t('Adding...');
var addToCartButton = $(form).find(this.options.addToCartButtonSelector);
addToCartButton.addClass(this.options.addToCartButtonDisabledClass);
addToCartButton.find('span').text(addToCartButtonTextWhileAdding);
addToCartButton.attr('title', addToCartButtonTextWhileAdding);
console.log('Hello 1');
,

enableAddToCartButton: function(form)
var addToCartButtonTextAdded = this.options.addToCartButtonTextAdded

);

return $.Ved_Mymodule.customCatalogAddToCart;
);


I am trying to print dummy messages in the console.



After this:
I have run static content deploy.
Reindex the data.
Cache cleaned and flushed.



But changes are not appearing.







magento2 overrides addtocart requirejs






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 28 '17 at 17:20









Prince Patel

14.1k65884




14.1k65884










asked Jul 25 '16 at 9:44









veduvedu

41211134




41211134












  • Please rename requirejs-config.js and correct the location app/code/Ved/Mymodule/view/frontend/requirejs-config.js.

    – Khoa TruongDinh
    Jul 26 '16 at 9:37












  • Changes are made as you said but still no success. But if I override via theme then it is working.

    – vedu
    Jul 26 '16 at 10:25


















  • Please rename requirejs-config.js and correct the location app/code/Ved/Mymodule/view/frontend/requirejs-config.js.

    – Khoa TruongDinh
    Jul 26 '16 at 9:37












  • Changes are made as you said but still no success. But if I override via theme then it is working.

    – vedu
    Jul 26 '16 at 10:25

















Please rename requirejs-config.js and correct the location app/code/Ved/Mymodule/view/frontend/requirejs-config.js.

– Khoa TruongDinh
Jul 26 '16 at 9:37






Please rename requirejs-config.js and correct the location app/code/Ved/Mymodule/view/frontend/requirejs-config.js.

– Khoa TruongDinh
Jul 26 '16 at 9:37














Changes are made as you said but still no success. But if I override via theme then it is working.

– vedu
Jul 26 '16 at 10:25






Changes are made as you said but still no success. But if I override via theme then it is working.

– vedu
Jul 26 '16 at 10:25











7 Answers
7






active

oldest

votes


















9














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.






share|improve this answer























  • Thank you very much, it worked. Previously, I was trying to override it by using a custom module (I have mentioned it in my question) but it did not work. By copying file to my theme it worked. But do not forget do fire : php bin/magento setup:upgrade

    – vedu
    Jul 26 '16 at 10:11



















6














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.






share|improve this answer






























    6














    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;
    ;
    );





    share|improve this answer

























    • I tried your steps but did not get any success. I have edited my question with my code.

      – vedu
      Jul 26 '16 at 5:27






    • 1





      @Khoa TruongDinh Perfect working.

      – Vithal Bariya
      Feb 5 '18 at 13:24











    • This is worked for me.

      – 55840
      Sep 22 '18 at 7:55


















    2














    Note: the below has been tested in 2.1.7




    Overriding any core files is considered bad practice.



    You can simply pass parameters into catalogAddToCart function which can be found towards the bottom of list.phtml



    If you look (don't edit or copy) at the catalog-add-to-cart.js file you'll see that it accepts parameters.



    vendor/magento/module-catalog/view/frontend/web/js/catalog-add-to-cart.js



    options: 
    processStart: null,
    processStop: null,
    bindSubmit: true,
    minicartSelector: '[data-block="minicart"]',
    messagesSelector: '[data-placeholder="messages"]',
    productStatusSelector: '.stock.available',
    addToCartButtonSelector: '.action.tocart',
    addToCartButtonDisabledClass: 'disabled',
    addToCartButtonTextWhileAdding: '',
    addToCartButtonTextAdded: '',
    addToCartButtonTextDefault: ''
    ,


    Next open list.phtml within your theme



    app/design/frontend/Namespace/theme/Magento_Catalog/template/product/list.phtml



    Towards the bottom of the page you'll find



    <?php if (!$block->isRedirectToCartEnabled()) : ?>
    <script type="text/x-magento-init">

    "[data-role=tocart-form], .form.map.checkout":
    "catalogAddToCart":


    </script>
    <?php endif; ?>


    Simply add parameters to the function...



    <?php if (!$block->isRedirectToCartEnabled()) : ?>
    <script type="text/x-magento-init">

    "[data-role=tocart-form], .form.map.checkout":
    "catalogAddToCart":
    "addToCartButtonTextDefault" : "<?php /* @escapeNotVerified */ echo __('Add to Cart') ?>"



    </script>
    <?php endif; ?>


    In my case I then added a translation for 'Add to Cart' within en_GB.csv but this might not be fit for your purpose so go ahead and edit it here directly.






    share|improve this answer






























      2














      Please try this...
      To translate the text of the "Add to cart","Adding..." and "Added" by json response follow below steps.



      Step 1:
      For Changes need in Product list page.
      Go to file path
      app/design/frontend/Your_Theme_Namespace/Theme_Name/Magento_Catalog/templates/product/list.phtml
      and replace below code on line around 121



      <script type="text/x-magento-init">

      "[data-role=tocart-form], .form.map.checkout":
      "catalogAddToCart":
      "product_sku": "<?php /* @escapeNotVerified */ echo $_product->getSku() ?>",
      "addToCartButtonTextDefault": "<?php echo __('Add to Cart'); ?>",
      "addToCartButtonTextWhileAdding": "<?php echo __('Adding...'); ?>",
      "addToCartButtonTextAdded": "<?php echo __('Added'); ?>"



      </script>


      Step 2:
      For changes need Product view page.
      Go to file path
      app/design/frontend/Your_Theme_Namespace/Theme_Name/Magento_Catalog/templates/product/view/addtocart.phtml and replace code on line around 54



       <script>
      require([
      'jquery',
      'mage/mage',
      'Magento_Catalog/product/view/validation',
      'Magento_Catalog/js/catalog-add-to-cart'
      ], function ($)
      'use strict';
      $('#product_addtocart_form').mage('validation',
      radioCheckboxClosest: '.nested',
      submitHandler: function (form)
      var widget = $(form).catalogAddToCart(
      bindSubmit: false,
      "addToCartButtonTextDefault": "<?php echo __('Add to Cart'); ?>",
      "addToCartButtonTextWhileAdding": "<?php echo __('Adding...'); ?>",
      "addToCartButtonTextAdded": "<?php echo __('Added'); ?>"
      );

      widget.catalogAddToCart('submitForm', $(form));

      return false;

      );
      );
      </script>


      Run below commands:



      1. php bin/magento setup:static-content:deploy en_US ja_JP zh_Hans_CN


      2. php bin/magento cache:flush
        I have try this and it's working for me.






      share|improve this answer






























        1














        You can extend the catalog add to cart instead of overriding the entire file. This will allow you to override certain functions and add in custom options to suit your needs - it looks like you want to do this.



        This is a better approach as it uses the original functionality and then you change what you need rather than copying everything.



        Just make sure to require it within your custom catalog add to cart JS as shown in this example.



        requirejs-config.js



        var config = 
        map:
        '*':
        catalogAddToCart:'Ved_Mymodule/js/customCatalogAddToCart'


        ;


        customCatalogAddToCart.js



        define([
        'jquery',
        'mage/translate',
        'jquery/ui',
        'Magento_Catalog/js/catalog-add-to-cart' // Important, require the original!
        ], function($, $t)
        'use strict';

        $.widget('Ved_Mymodule.catalogAddToCart', $.mage.catalogAddToCart,
        options:
        customOption: 'hello!'
        ,

        enableAddToCartButton: function(form)

        console.log('extended the original add to cart.');
        console.log('my new option', this.options.customOption);


        );

        return $.Ved_Mymodule.catalogAddToCart;
        );


        I've used this solution successfully to edit the cart JS, hope this helps!






        share|improve this answer






























          0














          Doing it by CSV file is the best and simplest way in Magento 2!




          1. Create folder i18n in your custom module as:



            app/code/Vendor/Module/i18n




          2. Create here file en_US.csv
            and write Label that you want to change as:



            "Add to Cart","Custom Label"


          You can change pretty good number of labels by this way like:



          "Add to Cart","Add to Order"
          "Go to Checkout","Complete Order"
          "Shopping Cart","Current Order"
          "Proceed to Checkout","Proceed to Confirm"
          "Summary","Details"
          "Estimate Shipping and Tax","Aproximate Sum"
          "You added %1 to your shopping cart.","Successfully added %1 to your current order."
          "Add Your Review","Add Review"


          Good to see other answers :)






          share|improve this answer























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "479"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f127243%2fchanging-add-to-cart-button-text-in-magento-2-1-0-overriding-js-file%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            7 Answers
            7






            active

            oldest

            votes








            7 Answers
            7






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            9














            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.






            share|improve this answer























            • Thank you very much, it worked. Previously, I was trying to override it by using a custom module (I have mentioned it in my question) but it did not work. By copying file to my theme it worked. But do not forget do fire : php bin/magento setup:upgrade

              – vedu
              Jul 26 '16 at 10:11
















            9














            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.






            share|improve this answer























            • Thank you very much, it worked. Previously, I was trying to override it by using a custom module (I have mentioned it in my question) but it did not work. By copying file to my theme it worked. But do not forget do fire : php bin/magento setup:upgrade

              – vedu
              Jul 26 '16 at 10:11














            9












            9








            9







            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.






            share|improve this answer













            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.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jul 26 '16 at 9:35









            Suresh ChikaniSuresh Chikani

            10.6k53673




            10.6k53673












            • Thank you very much, it worked. Previously, I was trying to override it by using a custom module (I have mentioned it in my question) but it did not work. By copying file to my theme it worked. But do not forget do fire : php bin/magento setup:upgrade

              – vedu
              Jul 26 '16 at 10:11


















            • Thank you very much, it worked. Previously, I was trying to override it by using a custom module (I have mentioned it in my question) but it did not work. By copying file to my theme it worked. But do not forget do fire : php bin/magento setup:upgrade

              – vedu
              Jul 26 '16 at 10:11

















            Thank you very much, it worked. Previously, I was trying to override it by using a custom module (I have mentioned it in my question) but it did not work. By copying file to my theme it worked. But do not forget do fire : php bin/magento setup:upgrade

            – vedu
            Jul 26 '16 at 10:11






            Thank you very much, it worked. Previously, I was trying to override it by using a custom module (I have mentioned it in my question) but it did not work. By copying file to my theme it worked. But do not forget do fire : php bin/magento setup:upgrade

            – vedu
            Jul 26 '16 at 10:11














            6














            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.






            share|improve this answer



























              6














              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.






              share|improve this answer

























                6












                6








                6







                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.






                share|improve this answer













                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.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jul 25 '16 at 9:51









                RushviRushvi

                2,4331830




                2,4331830





















                    6














                    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;
                    ;
                    );





                    share|improve this answer

























                    • I tried your steps but did not get any success. I have edited my question with my code.

                      – vedu
                      Jul 26 '16 at 5:27






                    • 1





                      @Khoa TruongDinh Perfect working.

                      – Vithal Bariya
                      Feb 5 '18 at 13:24











                    • This is worked for me.

                      – 55840
                      Sep 22 '18 at 7:55















                    6














                    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;
                    ;
                    );





                    share|improve this answer

























                    • I tried your steps but did not get any success. I have edited my question with my code.

                      – vedu
                      Jul 26 '16 at 5:27






                    • 1





                      @Khoa TruongDinh Perfect working.

                      – Vithal Bariya
                      Feb 5 '18 at 13:24











                    • This is worked for me.

                      – 55840
                      Sep 22 '18 at 7:55













                    6












                    6








                    6







                    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;
                    ;
                    );





                    share|improve this answer















                    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;
                    ;
                    );






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Nov 29 '17 at 11:41

























                    answered Jul 25 '16 at 13:43









                    Khoa TruongDinhKhoa TruongDinh

                    22.6k64491




                    22.6k64491












                    • I tried your steps but did not get any success. I have edited my question with my code.

                      – vedu
                      Jul 26 '16 at 5:27






                    • 1





                      @Khoa TruongDinh Perfect working.

                      – Vithal Bariya
                      Feb 5 '18 at 13:24











                    • This is worked for me.

                      – 55840
                      Sep 22 '18 at 7:55

















                    • I tried your steps but did not get any success. I have edited my question with my code.

                      – vedu
                      Jul 26 '16 at 5:27






                    • 1





                      @Khoa TruongDinh Perfect working.

                      – Vithal Bariya
                      Feb 5 '18 at 13:24











                    • This is worked for me.

                      – 55840
                      Sep 22 '18 at 7:55
















                    I tried your steps but did not get any success. I have edited my question with my code.

                    – vedu
                    Jul 26 '16 at 5:27





                    I tried your steps but did not get any success. I have edited my question with my code.

                    – vedu
                    Jul 26 '16 at 5:27




                    1




                    1





                    @Khoa TruongDinh Perfect working.

                    – Vithal Bariya
                    Feb 5 '18 at 13:24





                    @Khoa TruongDinh Perfect working.

                    – Vithal Bariya
                    Feb 5 '18 at 13:24













                    This is worked for me.

                    – 55840
                    Sep 22 '18 at 7:55





                    This is worked for me.

                    – 55840
                    Sep 22 '18 at 7:55











                    2














                    Note: the below has been tested in 2.1.7




                    Overriding any core files is considered bad practice.



                    You can simply pass parameters into catalogAddToCart function which can be found towards the bottom of list.phtml



                    If you look (don't edit or copy) at the catalog-add-to-cart.js file you'll see that it accepts parameters.



                    vendor/magento/module-catalog/view/frontend/web/js/catalog-add-to-cart.js



                    options: 
                    processStart: null,
                    processStop: null,
                    bindSubmit: true,
                    minicartSelector: '[data-block="minicart"]',
                    messagesSelector: '[data-placeholder="messages"]',
                    productStatusSelector: '.stock.available',
                    addToCartButtonSelector: '.action.tocart',
                    addToCartButtonDisabledClass: 'disabled',
                    addToCartButtonTextWhileAdding: '',
                    addToCartButtonTextAdded: '',
                    addToCartButtonTextDefault: ''
                    ,


                    Next open list.phtml within your theme



                    app/design/frontend/Namespace/theme/Magento_Catalog/template/product/list.phtml



                    Towards the bottom of the page you'll find



                    <?php if (!$block->isRedirectToCartEnabled()) : ?>
                    <script type="text/x-magento-init">

                    "[data-role=tocart-form], .form.map.checkout":
                    "catalogAddToCart":


                    </script>
                    <?php endif; ?>


                    Simply add parameters to the function...



                    <?php if (!$block->isRedirectToCartEnabled()) : ?>
                    <script type="text/x-magento-init">

                    "[data-role=tocart-form], .form.map.checkout":
                    "catalogAddToCart":
                    "addToCartButtonTextDefault" : "<?php /* @escapeNotVerified */ echo __('Add to Cart') ?>"



                    </script>
                    <?php endif; ?>


                    In my case I then added a translation for 'Add to Cart' within en_GB.csv but this might not be fit for your purpose so go ahead and edit it here directly.






                    share|improve this answer



























                      2














                      Note: the below has been tested in 2.1.7




                      Overriding any core files is considered bad practice.



                      You can simply pass parameters into catalogAddToCart function which can be found towards the bottom of list.phtml



                      If you look (don't edit or copy) at the catalog-add-to-cart.js file you'll see that it accepts parameters.



                      vendor/magento/module-catalog/view/frontend/web/js/catalog-add-to-cart.js



                      options: 
                      processStart: null,
                      processStop: null,
                      bindSubmit: true,
                      minicartSelector: '[data-block="minicart"]',
                      messagesSelector: '[data-placeholder="messages"]',
                      productStatusSelector: '.stock.available',
                      addToCartButtonSelector: '.action.tocart',
                      addToCartButtonDisabledClass: 'disabled',
                      addToCartButtonTextWhileAdding: '',
                      addToCartButtonTextAdded: '',
                      addToCartButtonTextDefault: ''
                      ,


                      Next open list.phtml within your theme



                      app/design/frontend/Namespace/theme/Magento_Catalog/template/product/list.phtml



                      Towards the bottom of the page you'll find



                      <?php if (!$block->isRedirectToCartEnabled()) : ?>
                      <script type="text/x-magento-init">

                      "[data-role=tocart-form], .form.map.checkout":
                      "catalogAddToCart":


                      </script>
                      <?php endif; ?>


                      Simply add parameters to the function...



                      <?php if (!$block->isRedirectToCartEnabled()) : ?>
                      <script type="text/x-magento-init">

                      "[data-role=tocart-form], .form.map.checkout":
                      "catalogAddToCart":
                      "addToCartButtonTextDefault" : "<?php /* @escapeNotVerified */ echo __('Add to Cart') ?>"



                      </script>
                      <?php endif; ?>


                      In my case I then added a translation for 'Add to Cart' within en_GB.csv but this might not be fit for your purpose so go ahead and edit it here directly.






                      share|improve this answer

























                        2












                        2








                        2







                        Note: the below has been tested in 2.1.7




                        Overriding any core files is considered bad practice.



                        You can simply pass parameters into catalogAddToCart function which can be found towards the bottom of list.phtml



                        If you look (don't edit or copy) at the catalog-add-to-cart.js file you'll see that it accepts parameters.



                        vendor/magento/module-catalog/view/frontend/web/js/catalog-add-to-cart.js



                        options: 
                        processStart: null,
                        processStop: null,
                        bindSubmit: true,
                        minicartSelector: '[data-block="minicart"]',
                        messagesSelector: '[data-placeholder="messages"]',
                        productStatusSelector: '.stock.available',
                        addToCartButtonSelector: '.action.tocart',
                        addToCartButtonDisabledClass: 'disabled',
                        addToCartButtonTextWhileAdding: '',
                        addToCartButtonTextAdded: '',
                        addToCartButtonTextDefault: ''
                        ,


                        Next open list.phtml within your theme



                        app/design/frontend/Namespace/theme/Magento_Catalog/template/product/list.phtml



                        Towards the bottom of the page you'll find



                        <?php if (!$block->isRedirectToCartEnabled()) : ?>
                        <script type="text/x-magento-init">

                        "[data-role=tocart-form], .form.map.checkout":
                        "catalogAddToCart":


                        </script>
                        <?php endif; ?>


                        Simply add parameters to the function...



                        <?php if (!$block->isRedirectToCartEnabled()) : ?>
                        <script type="text/x-magento-init">

                        "[data-role=tocart-form], .form.map.checkout":
                        "catalogAddToCart":
                        "addToCartButtonTextDefault" : "<?php /* @escapeNotVerified */ echo __('Add to Cart') ?>"



                        </script>
                        <?php endif; ?>


                        In my case I then added a translation for 'Add to Cart' within en_GB.csv but this might not be fit for your purpose so go ahead and edit it here directly.






                        share|improve this answer













                        Note: the below has been tested in 2.1.7




                        Overriding any core files is considered bad practice.



                        You can simply pass parameters into catalogAddToCart function which can be found towards the bottom of list.phtml



                        If you look (don't edit or copy) at the catalog-add-to-cart.js file you'll see that it accepts parameters.



                        vendor/magento/module-catalog/view/frontend/web/js/catalog-add-to-cart.js



                        options: 
                        processStart: null,
                        processStop: null,
                        bindSubmit: true,
                        minicartSelector: '[data-block="minicart"]',
                        messagesSelector: '[data-placeholder="messages"]',
                        productStatusSelector: '.stock.available',
                        addToCartButtonSelector: '.action.tocart',
                        addToCartButtonDisabledClass: 'disabled',
                        addToCartButtonTextWhileAdding: '',
                        addToCartButtonTextAdded: '',
                        addToCartButtonTextDefault: ''
                        ,


                        Next open list.phtml within your theme



                        app/design/frontend/Namespace/theme/Magento_Catalog/template/product/list.phtml



                        Towards the bottom of the page you'll find



                        <?php if (!$block->isRedirectToCartEnabled()) : ?>
                        <script type="text/x-magento-init">

                        "[data-role=tocart-form], .form.map.checkout":
                        "catalogAddToCart":


                        </script>
                        <?php endif; ?>


                        Simply add parameters to the function...



                        <?php if (!$block->isRedirectToCartEnabled()) : ?>
                        <script type="text/x-magento-init">

                        "[data-role=tocart-form], .form.map.checkout":
                        "catalogAddToCart":
                        "addToCartButtonTextDefault" : "<?php /* @escapeNotVerified */ echo __('Add to Cart') ?>"



                        </script>
                        <?php endif; ?>


                        In my case I then added a translation for 'Add to Cart' within en_GB.csv but this might not be fit for your purpose so go ahead and edit it here directly.







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Jul 1 '17 at 13:23









                        Dan NorrisDan Norris

                        269110




                        269110





















                            2














                            Please try this...
                            To translate the text of the "Add to cart","Adding..." and "Added" by json response follow below steps.



                            Step 1:
                            For Changes need in Product list page.
                            Go to file path
                            app/design/frontend/Your_Theme_Namespace/Theme_Name/Magento_Catalog/templates/product/list.phtml
                            and replace below code on line around 121



                            <script type="text/x-magento-init">

                            "[data-role=tocart-form], .form.map.checkout":
                            "catalogAddToCart":
                            "product_sku": "<?php /* @escapeNotVerified */ echo $_product->getSku() ?>",
                            "addToCartButtonTextDefault": "<?php echo __('Add to Cart'); ?>",
                            "addToCartButtonTextWhileAdding": "<?php echo __('Adding...'); ?>",
                            "addToCartButtonTextAdded": "<?php echo __('Added'); ?>"



                            </script>


                            Step 2:
                            For changes need Product view page.
                            Go to file path
                            app/design/frontend/Your_Theme_Namespace/Theme_Name/Magento_Catalog/templates/product/view/addtocart.phtml and replace code on line around 54



                             <script>
                            require([
                            'jquery',
                            'mage/mage',
                            'Magento_Catalog/product/view/validation',
                            'Magento_Catalog/js/catalog-add-to-cart'
                            ], function ($)
                            'use strict';
                            $('#product_addtocart_form').mage('validation',
                            radioCheckboxClosest: '.nested',
                            submitHandler: function (form)
                            var widget = $(form).catalogAddToCart(
                            bindSubmit: false,
                            "addToCartButtonTextDefault": "<?php echo __('Add to Cart'); ?>",
                            "addToCartButtonTextWhileAdding": "<?php echo __('Adding...'); ?>",
                            "addToCartButtonTextAdded": "<?php echo __('Added'); ?>"
                            );

                            widget.catalogAddToCart('submitForm', $(form));

                            return false;

                            );
                            );
                            </script>


                            Run below commands:



                            1. php bin/magento setup:static-content:deploy en_US ja_JP zh_Hans_CN


                            2. php bin/magento cache:flush
                              I have try this and it's working for me.






                            share|improve this answer



























                              2














                              Please try this...
                              To translate the text of the "Add to cart","Adding..." and "Added" by json response follow below steps.



                              Step 1:
                              For Changes need in Product list page.
                              Go to file path
                              app/design/frontend/Your_Theme_Namespace/Theme_Name/Magento_Catalog/templates/product/list.phtml
                              and replace below code on line around 121



                              <script type="text/x-magento-init">

                              "[data-role=tocart-form], .form.map.checkout":
                              "catalogAddToCart":
                              "product_sku": "<?php /* @escapeNotVerified */ echo $_product->getSku() ?>",
                              "addToCartButtonTextDefault": "<?php echo __('Add to Cart'); ?>",
                              "addToCartButtonTextWhileAdding": "<?php echo __('Adding...'); ?>",
                              "addToCartButtonTextAdded": "<?php echo __('Added'); ?>"



                              </script>


                              Step 2:
                              For changes need Product view page.
                              Go to file path
                              app/design/frontend/Your_Theme_Namespace/Theme_Name/Magento_Catalog/templates/product/view/addtocart.phtml and replace code on line around 54



                               <script>
                              require([
                              'jquery',
                              'mage/mage',
                              'Magento_Catalog/product/view/validation',
                              'Magento_Catalog/js/catalog-add-to-cart'
                              ], function ($)
                              'use strict';
                              $('#product_addtocart_form').mage('validation',
                              radioCheckboxClosest: '.nested',
                              submitHandler: function (form)
                              var widget = $(form).catalogAddToCart(
                              bindSubmit: false,
                              "addToCartButtonTextDefault": "<?php echo __('Add to Cart'); ?>",
                              "addToCartButtonTextWhileAdding": "<?php echo __('Adding...'); ?>",
                              "addToCartButtonTextAdded": "<?php echo __('Added'); ?>"
                              );

                              widget.catalogAddToCart('submitForm', $(form));

                              return false;

                              );
                              );
                              </script>


                              Run below commands:



                              1. php bin/magento setup:static-content:deploy en_US ja_JP zh_Hans_CN


                              2. php bin/magento cache:flush
                                I have try this and it's working for me.






                              share|improve this answer

























                                2












                                2








                                2







                                Please try this...
                                To translate the text of the "Add to cart","Adding..." and "Added" by json response follow below steps.



                                Step 1:
                                For Changes need in Product list page.
                                Go to file path
                                app/design/frontend/Your_Theme_Namespace/Theme_Name/Magento_Catalog/templates/product/list.phtml
                                and replace below code on line around 121



                                <script type="text/x-magento-init">

                                "[data-role=tocart-form], .form.map.checkout":
                                "catalogAddToCart":
                                "product_sku": "<?php /* @escapeNotVerified */ echo $_product->getSku() ?>",
                                "addToCartButtonTextDefault": "<?php echo __('Add to Cart'); ?>",
                                "addToCartButtonTextWhileAdding": "<?php echo __('Adding...'); ?>",
                                "addToCartButtonTextAdded": "<?php echo __('Added'); ?>"



                                </script>


                                Step 2:
                                For changes need Product view page.
                                Go to file path
                                app/design/frontend/Your_Theme_Namespace/Theme_Name/Magento_Catalog/templates/product/view/addtocart.phtml and replace code on line around 54



                                 <script>
                                require([
                                'jquery',
                                'mage/mage',
                                'Magento_Catalog/product/view/validation',
                                'Magento_Catalog/js/catalog-add-to-cart'
                                ], function ($)
                                'use strict';
                                $('#product_addtocart_form').mage('validation',
                                radioCheckboxClosest: '.nested',
                                submitHandler: function (form)
                                var widget = $(form).catalogAddToCart(
                                bindSubmit: false,
                                "addToCartButtonTextDefault": "<?php echo __('Add to Cart'); ?>",
                                "addToCartButtonTextWhileAdding": "<?php echo __('Adding...'); ?>",
                                "addToCartButtonTextAdded": "<?php echo __('Added'); ?>"
                                );

                                widget.catalogAddToCart('submitForm', $(form));

                                return false;

                                );
                                );
                                </script>


                                Run below commands:



                                1. php bin/magento setup:static-content:deploy en_US ja_JP zh_Hans_CN


                                2. php bin/magento cache:flush
                                  I have try this and it's working for me.






                                share|improve this answer













                                Please try this...
                                To translate the text of the "Add to cart","Adding..." and "Added" by json response follow below steps.



                                Step 1:
                                For Changes need in Product list page.
                                Go to file path
                                app/design/frontend/Your_Theme_Namespace/Theme_Name/Magento_Catalog/templates/product/list.phtml
                                and replace below code on line around 121



                                <script type="text/x-magento-init">

                                "[data-role=tocart-form], .form.map.checkout":
                                "catalogAddToCart":
                                "product_sku": "<?php /* @escapeNotVerified */ echo $_product->getSku() ?>",
                                "addToCartButtonTextDefault": "<?php echo __('Add to Cart'); ?>",
                                "addToCartButtonTextWhileAdding": "<?php echo __('Adding...'); ?>",
                                "addToCartButtonTextAdded": "<?php echo __('Added'); ?>"



                                </script>


                                Step 2:
                                For changes need Product view page.
                                Go to file path
                                app/design/frontend/Your_Theme_Namespace/Theme_Name/Magento_Catalog/templates/product/view/addtocart.phtml and replace code on line around 54



                                 <script>
                                require([
                                'jquery',
                                'mage/mage',
                                'Magento_Catalog/product/view/validation',
                                'Magento_Catalog/js/catalog-add-to-cart'
                                ], function ($)
                                'use strict';
                                $('#product_addtocart_form').mage('validation',
                                radioCheckboxClosest: '.nested',
                                submitHandler: function (form)
                                var widget = $(form).catalogAddToCart(
                                bindSubmit: false,
                                "addToCartButtonTextDefault": "<?php echo __('Add to Cart'); ?>",
                                "addToCartButtonTextWhileAdding": "<?php echo __('Adding...'); ?>",
                                "addToCartButtonTextAdded": "<?php echo __('Added'); ?>"
                                );

                                widget.catalogAddToCart('submitForm', $(form));

                                return false;

                                );
                                );
                                </script>


                                Run below commands:



                                1. php bin/magento setup:static-content:deploy en_US ja_JP zh_Hans_CN


                                2. php bin/magento cache:flush
                                  I have try this and it's working for me.







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered May 18 '18 at 14:54









                                Bhaumik RanaBhaumik Rana

                                494




                                494





















                                    1














                                    You can extend the catalog add to cart instead of overriding the entire file. This will allow you to override certain functions and add in custom options to suit your needs - it looks like you want to do this.



                                    This is a better approach as it uses the original functionality and then you change what you need rather than copying everything.



                                    Just make sure to require it within your custom catalog add to cart JS as shown in this example.



                                    requirejs-config.js



                                    var config = 
                                    map:
                                    '*':
                                    catalogAddToCart:'Ved_Mymodule/js/customCatalogAddToCart'


                                    ;


                                    customCatalogAddToCart.js



                                    define([
                                    'jquery',
                                    'mage/translate',
                                    'jquery/ui',
                                    'Magento_Catalog/js/catalog-add-to-cart' // Important, require the original!
                                    ], function($, $t)
                                    'use strict';

                                    $.widget('Ved_Mymodule.catalogAddToCart', $.mage.catalogAddToCart,
                                    options:
                                    customOption: 'hello!'
                                    ,

                                    enableAddToCartButton: function(form)

                                    console.log('extended the original add to cart.');
                                    console.log('my new option', this.options.customOption);


                                    );

                                    return $.Ved_Mymodule.catalogAddToCart;
                                    );


                                    I've used this solution successfully to edit the cart JS, hope this helps!






                                    share|improve this answer



























                                      1














                                      You can extend the catalog add to cart instead of overriding the entire file. This will allow you to override certain functions and add in custom options to suit your needs - it looks like you want to do this.



                                      This is a better approach as it uses the original functionality and then you change what you need rather than copying everything.



                                      Just make sure to require it within your custom catalog add to cart JS as shown in this example.



                                      requirejs-config.js



                                      var config = 
                                      map:
                                      '*':
                                      catalogAddToCart:'Ved_Mymodule/js/customCatalogAddToCart'


                                      ;


                                      customCatalogAddToCart.js



                                      define([
                                      'jquery',
                                      'mage/translate',
                                      'jquery/ui',
                                      'Magento_Catalog/js/catalog-add-to-cart' // Important, require the original!
                                      ], function($, $t)
                                      'use strict';

                                      $.widget('Ved_Mymodule.catalogAddToCart', $.mage.catalogAddToCart,
                                      options:
                                      customOption: 'hello!'
                                      ,

                                      enableAddToCartButton: function(form)

                                      console.log('extended the original add to cart.');
                                      console.log('my new option', this.options.customOption);


                                      );

                                      return $.Ved_Mymodule.catalogAddToCart;
                                      );


                                      I've used this solution successfully to edit the cart JS, hope this helps!






                                      share|improve this answer

























                                        1












                                        1








                                        1







                                        You can extend the catalog add to cart instead of overriding the entire file. This will allow you to override certain functions and add in custom options to suit your needs - it looks like you want to do this.



                                        This is a better approach as it uses the original functionality and then you change what you need rather than copying everything.



                                        Just make sure to require it within your custom catalog add to cart JS as shown in this example.



                                        requirejs-config.js



                                        var config = 
                                        map:
                                        '*':
                                        catalogAddToCart:'Ved_Mymodule/js/customCatalogAddToCart'


                                        ;


                                        customCatalogAddToCart.js



                                        define([
                                        'jquery',
                                        'mage/translate',
                                        'jquery/ui',
                                        'Magento_Catalog/js/catalog-add-to-cart' // Important, require the original!
                                        ], function($, $t)
                                        'use strict';

                                        $.widget('Ved_Mymodule.catalogAddToCart', $.mage.catalogAddToCart,
                                        options:
                                        customOption: 'hello!'
                                        ,

                                        enableAddToCartButton: function(form)

                                        console.log('extended the original add to cart.');
                                        console.log('my new option', this.options.customOption);


                                        );

                                        return $.Ved_Mymodule.catalogAddToCart;
                                        );


                                        I've used this solution successfully to edit the cart JS, hope this helps!






                                        share|improve this answer













                                        You can extend the catalog add to cart instead of overriding the entire file. This will allow you to override certain functions and add in custom options to suit your needs - it looks like you want to do this.



                                        This is a better approach as it uses the original functionality and then you change what you need rather than copying everything.



                                        Just make sure to require it within your custom catalog add to cart JS as shown in this example.



                                        requirejs-config.js



                                        var config = 
                                        map:
                                        '*':
                                        catalogAddToCart:'Ved_Mymodule/js/customCatalogAddToCart'


                                        ;


                                        customCatalogAddToCart.js



                                        define([
                                        'jquery',
                                        'mage/translate',
                                        'jquery/ui',
                                        'Magento_Catalog/js/catalog-add-to-cart' // Important, require the original!
                                        ], function($, $t)
                                        'use strict';

                                        $.widget('Ved_Mymodule.catalogAddToCart', $.mage.catalogAddToCart,
                                        options:
                                        customOption: 'hello!'
                                        ,

                                        enableAddToCartButton: function(form)

                                        console.log('extended the original add to cart.');
                                        console.log('my new option', this.options.customOption);


                                        );

                                        return $.Ved_Mymodule.catalogAddToCart;
                                        );


                                        I've used this solution successfully to edit the cart JS, hope this helps!







                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Jun 5 '17 at 16:24









                                        jasonujmaalvisjasonujmaalvis

                                        362




                                        362





















                                            0














                                            Doing it by CSV file is the best and simplest way in Magento 2!




                                            1. Create folder i18n in your custom module as:



                                              app/code/Vendor/Module/i18n




                                            2. Create here file en_US.csv
                                              and write Label that you want to change as:



                                              "Add to Cart","Custom Label"


                                            You can change pretty good number of labels by this way like:



                                            "Add to Cart","Add to Order"
                                            "Go to Checkout","Complete Order"
                                            "Shopping Cart","Current Order"
                                            "Proceed to Checkout","Proceed to Confirm"
                                            "Summary","Details"
                                            "Estimate Shipping and Tax","Aproximate Sum"
                                            "You added %1 to your shopping cart.","Successfully added %1 to your current order."
                                            "Add Your Review","Add Review"


                                            Good to see other answers :)






                                            share|improve this answer



























                                              0














                                              Doing it by CSV file is the best and simplest way in Magento 2!




                                              1. Create folder i18n in your custom module as:



                                                app/code/Vendor/Module/i18n




                                              2. Create here file en_US.csv
                                                and write Label that you want to change as:



                                                "Add to Cart","Custom Label"


                                              You can change pretty good number of labels by this way like:



                                              "Add to Cart","Add to Order"
                                              "Go to Checkout","Complete Order"
                                              "Shopping Cart","Current Order"
                                              "Proceed to Checkout","Proceed to Confirm"
                                              "Summary","Details"
                                              "Estimate Shipping and Tax","Aproximate Sum"
                                              "You added %1 to your shopping cart.","Successfully added %1 to your current order."
                                              "Add Your Review","Add Review"


                                              Good to see other answers :)






                                              share|improve this answer

























                                                0












                                                0








                                                0







                                                Doing it by CSV file is the best and simplest way in Magento 2!




                                                1. Create folder i18n in your custom module as:



                                                  app/code/Vendor/Module/i18n




                                                2. Create here file en_US.csv
                                                  and write Label that you want to change as:



                                                  "Add to Cart","Custom Label"


                                                You can change pretty good number of labels by this way like:



                                                "Add to Cart","Add to Order"
                                                "Go to Checkout","Complete Order"
                                                "Shopping Cart","Current Order"
                                                "Proceed to Checkout","Proceed to Confirm"
                                                "Summary","Details"
                                                "Estimate Shipping and Tax","Aproximate Sum"
                                                "You added %1 to your shopping cart.","Successfully added %1 to your current order."
                                                "Add Your Review","Add Review"


                                                Good to see other answers :)






                                                share|improve this answer













                                                Doing it by CSV file is the best and simplest way in Magento 2!




                                                1. Create folder i18n in your custom module as:



                                                  app/code/Vendor/Module/i18n




                                                2. Create here file en_US.csv
                                                  and write Label that you want to change as:



                                                  "Add to Cart","Custom Label"


                                                You can change pretty good number of labels by this way like:



                                                "Add to Cart","Add to Order"
                                                "Go to Checkout","Complete Order"
                                                "Shopping Cart","Current Order"
                                                "Proceed to Checkout","Proceed to Confirm"
                                                "Summary","Details"
                                                "Estimate Shipping and Tax","Aproximate Sum"
                                                "You added %1 to your shopping cart.","Successfully added %1 to your current order."
                                                "Add Your Review","Add Review"


                                                Good to see other answers :)







                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered Dec 5 '18 at 12:04









                                                Ajwad TaqviAjwad Taqvi

                                                502116




                                                502116



























                                                    draft saved

                                                    draft discarded
















































                                                    Thanks for contributing an answer to Magento Stack Exchange!


                                                    • Please be sure to answer the question. Provide details and share your research!

                                                    But avoid


                                                    • Asking for help, clarification, or responding to other answers.

                                                    • Making statements based on opinion; back them up with references or personal experience.

                                                    To learn more, see our tips on writing great answers.




                                                    draft saved


                                                    draft discarded














                                                    StackExchange.ready(
                                                    function ()
                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f127243%2fchanging-add-to-cart-button-text-in-magento-2-1-0-overriding-js-file%23new-answer', 'question_page');

                                                    );

                                                    Post as a guest















                                                    Required, but never shown





















































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown

































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown







                                                    Popular posts from this blog

                                                    Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

                                                    Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

                                                    Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림