Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

40 lignes
1.2 KiB

  1. /**
  2. * Copyright © Magento, Inc. All rights reserved.
  3. * See COPYING.txt for license details.
  4. */
  5. define([
  6. 'jquery',
  7. 'jquery-ui-modules/widget'
  8. ], function ($) {
  9. 'use strict';
  10. $.widget('mage.checkoutBalance', {
  11. /**
  12. * Initialize store credit events
  13. * @private
  14. */
  15. _create: function () {
  16. this.eventData = {
  17. price: this.options.balance,
  18. totalPrice: 0
  19. };
  20. this.element.on('change', $.proxy(function (e) {
  21. if ($(e.target).is(':checked')) {
  22. this.eventData.price = -1 * this.options.balance;
  23. } else {
  24. if (this.options.amountSubstracted) { //eslint-disable-line no-lonely-if
  25. this.eventData.price = parseFloat(this.options.usedAmount);
  26. this.options.amountSubstracted = false;
  27. } else {
  28. this.eventData.price = parseFloat(this.options.balance);
  29. }
  30. }
  31. this.element.trigger('updateCheckoutPrice', this.eventData);
  32. }, this));
  33. }
  34. });
  35. return $.mage.checkoutBalance;
  36. });