Guest User

Untitled

a guest
Dec 18th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. <button type="submit" id="button_next" data-bind="enable: isDisabled , text: getValue()" ></button>
  2.  
  3. /*global define*/
  4. define(
  5. ['ko',
  6. 'jquery',
  7. 'Magento_Checkout/js/view/summary/abstract-total',
  8. 'Magento_Checkout/js/model/quote',
  9. 'Magento_Checkout/js/model/step-navigator',
  10. 'mage/validation',
  11. 'mage/translate'
  12. ],
  13. function (ko,$,Component, quote,stepNavigator) {
  14. "use strict";
  15. return Component.extend({
  16. defaults: {
  17. template: 'Magento_Checkout/button_next'
  18. },
  19. initialize: function () {
  20. this._super();
  21. return this;
  22. },
  23. initObservable: function () {
  24. console.log("INIT OBSERVABLE");
  25. this._super();
  26.  
  27. this.isDisabled = function() {
  28. //@TODO, check is not ok.
  29. console.log("********************* IS DISABLED ?? *********************");
  30. return true;
  31. }
  32. ;
  33. return this;
  34. },
  35. nextAction : function(){
  36. //@TODO
  37. },
  38. getPureValue: function() {
  39. var totals = quote.getTotals()();
  40. if (totals) {
  41. return totals.grand_total;
  42. }
  43. return quote.grand_total;
  44. },
  45. getValue: function() {
  46. console.log('GET VALUE BUTTON NEXT');
  47.  
  48. if(stepNavigator.getActiveItemIndex() == 0)
  49. return $.mage.__('#BUTTON_NEXT#StepShipping');
  50. var price = this.getPureValue();
  51. if(price <= 0) {
  52. return $.mage.__('Free');
  53. }
  54. return $.mage.__('#BUTTON_NEXT#StepBilling') +' '+this.getFormattedPrice(price);
  55. }
  56. });
  57. }
  58. );
Add Comment
Please, Sign In to add comment