2

need to know is how to update the order summary like reloading the component when we do something like choosing a select payment terms

enter image description here

My code:

view/frontend/web/js/payment/method-renderer/checkmo-method.js

getFee: function () {
    return window.checkoutConfig.payment.checkmo.fee;
}

view/frontend/web/js/action/payment/select-payment-method.js

    define(
    [
        'jquery',
        'ko',
        'Magento_Checkout/js/model/quote',
        'PCarts_PaymentFee/js/action/checkout/cart/totals'
    ],
    function($, ko ,quote, totals) {
        'use strict';
        var isLoading = ko.observable(false);

        return function (paymentMethod) {
            quote.paymentMethod(paymentMethod);
            totals(isLoading, paymentMethod['method']);
        };
    }
);

view/frontend/web/template/payment/checkmo.html

<!-- ko if getFee() -->
    <p data-bind="text: '· Select payment term:'"></p>
    <!-- ko text: console.log(getFee()) --><!-- /ko -->
    <!-- ko foreach: getFee() -->
    <p>
    <input type="radio"
           name="payment[fee]"
           class="radio"
           data-bind="attr: {'id': fee}, value: fee" />
    <label data-bind="attr: {'for': fee}" class="label"><span data-bind="text: description + ' (financial cost: '+fee+'%)'"></span></label>
    </p>
    <!--/ko-->
    <!--/ko-->

Tanks for the help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.