Jquery Widget

TQ/JsMixin/view/frontend/requirejs-config.js

/**
 * Copyright © 2009-2017 TQ Group. All rights reserved.
 * See LICENSE.txt for license details.
 */
var config = {
    config: {
        mixins: {
            'Magento_Catalog/js/catalog-add-to-cart': {
                'TQ_JsMixin/js/catalog-add-to-cart': true
            }
        }
    }
};

TQ/JsMixin/view/frontend/web/js/catalog-add-to-cart.js

/**
 * Copyright © 2009-2017 TQ Group. All rights reserved.
 * See LICENSE.txt for license details.
 */
define([
    'jquery',
    'mage/translate'
], function ($, $t) {
    return function (widget) {
        $.widget('vaimo.catalogAddToCart', widget, {
            enableAddToCartButton: function(form) {
                var addToCartButtonTextAdded = this.options.addToCartButtonTextAdded || $t('Added');
                var self = this,
                    addToCartButton = $(form).find(this.options.addToCartButtonSelector);

                addToCartButton.find('span').text(addToCartButtonTextAdded);
                addToCartButton.attr('title', addToCartButtonTextAdded);

                setTimeout(function() {
                    var addToCartButtonTextDefault = self.options.addToCartButtonTextDefault || $t('Add more');
                    addToCartButton.removeClass(self.options.addToCartButtonDisabledClass);
                    addToCartButton.find('span').text(addToCartButtonTextDefault);
                    addToCartButton.attr('title', addToCartButtonTextDefault);
                }, 1000);
            }
        });
        return $.vaimo.catalogAddToCart;
    };
});
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s