Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <button type="submit" id="button_next" data-bind="enable: isDisabled , text: getValue()" ></button>
- /*global define*/
- define(
- ['ko',
- 'jquery',
- 'Magento_Checkout/js/view/summary/abstract-total',
- 'Magento_Checkout/js/model/quote',
- 'Magento_Checkout/js/model/step-navigator',
- 'mage/validation',
- 'mage/translate'
- ],
- function (ko,$,Component, quote,stepNavigator) {
- "use strict";
- return Component.extend({
- defaults: {
- template: 'Magento_Checkout/button_next'
- },
- initialize: function () {
- this._super();
- return this;
- },
- initObservable: function () {
- console.log("INIT OBSERVABLE");
- this._super();
- this.isDisabled = function() {
- //@TODO, check is not ok.
- console.log("********************* IS DISABLED ?? *********************");
- return true;
- }
- ;
- return this;
- },
- nextAction : function(){
- //@TODO
- },
- getPureValue: function() {
- var totals = quote.getTotals()();
- if (totals) {
- return totals.grand_total;
- }
- return quote.grand_total;
- },
- getValue: function() {
- console.log('GET VALUE BUTTON NEXT');
- if(stepNavigator.getActiveItemIndex() == 0)
- return $.mage.__('#BUTTON_NEXT#StepShipping');
- var price = this.getPureValue();
- if(price <= 0) {
- return $.mage.__('Free');
- }
- return $.mage.__('#BUTTON_NEXT#StepBilling') +' '+this.getFormattedPrice(price);
- }
- });
- }
- );
Add Comment
Please, Sign In to add comment