0

I want to do calculation based on that value in order summary extra field enter image description here

 getValue: function() {
                var price = 0;
                if (this.totals()) {
                    price = totals.getSegment('fee').value ;
                var tex = totals.getSegment('fee').value ;
                price = (this.totals().subtotal) / tex;
                }
                // price = 101;
                return this.getFormattedPrice(price);

that was by fee.js file code I already do code but they not reflected can any one help me.

1 Answer 1

0

You can do that code in that defined file see Extention/Module/view/frontend/web/js/view/checkout/cart/totals

define([
        'ko',
        'uiComponent',
        'Magento_Checkout/js/model/quote',
        'Magento_Catalog/js/price-utils',
        'Magento_Checkout/js/model/totals'

    ], function (ko, Component, quote, priceUtils, totals) {
        'use strict';
        var show_hide_Extrafee_blockConfig = window.checkoutConfig.show_hide_Extrafee_block;
        var fee_label = window.checkoutConfig.fee_label;
        var custom_tax_percentage = window.checkoutConfig.custom_fee_amount;
        var subtotal_amount =  parseFloat(totals.totals()['subtotal']);
        var custom_fee_amount = subtotal_amount/custom_tax_percentage;
        return Component.extend({

            totals: quote.getTotals(),
            canVisibleExtrafeeBlock: show_hide_Extrafee_blockConfig,
            getFormattedPrice: ko.observable(priceUtils.formatPrice(custom_fee_amount, quote.getPriceFormat())),
            getFeeLabel:ko.observable(fee_label),
            isDisplayed: function () {
                return this.getValue() != 0;
            },
            getValue: function() {
                var price = 0;
                if (this.totals() && totals.getSegment('fee')) {
                    price = totals.getSegment('fee').value;
                }
                // price = 1;
                return price;
            }
        });
    });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.