2

Like I have applied a checkbox on payment page for using it as credit score inspite of money. There is problem when my credit is 100 % used i.e. by using credit score grand total becomes 0. In that case Zero checkout payment should come but its not coming and when i reload the page that zero checkout payment method comes is there any way to refresh payment method list on my checkbox click. You can check in below image what i am talking about.

enter image description here

3
  • Can describe using which method you added checkbox there in payment section? Feb 17, 2017 at 13:11
  • its done by overriding , checkout_index_index.xml and then put your js and html to show checkbox Feb 19, 2017 at 17:54
  • Can you please share your full code here, I have same requirement. Nov 13, 2017 at 10:51

1 Answer 1

5

you can use some code like this:

define([
    'uiComponent',
    'Magento_Checkout/js/model/quote',
    'ko',
    'jquery',
    'Magento_Checkout/js/action/get-totals',
    'Magento_Checkout/js/model/full-screen-loader',
     'Magento_Checkout/js/action/get-payment-information'
], function (Component,quote,ko , jQuery, getTotalsAction, fullScreenLoader,getPaymentInformationAction) {
    'use strict';

    // some code

     return Component.extend({
        //some code
        reloadPayment: function() {
            var self = this;

            fullScreenLoader.startLoader();
            jQuery.ajax({
                    url: URL,
                    type: "POST",
                    data: {
                        checked: self.creditValue(),
                        quote_id: quoteId
                     },
                    success: function(response) {
                        if (response) {
                            var deferred = jQuery.Deferred();
                            getTotalsAction([], deferred);
                            // var deferred = $.Deferred();
                             fullScreenLoader.stopLoader();
                            getPaymentInformationAction(deferred);
                            jQuery.when(deferred).done(function () {
                                isApplied(false);
                                totals.isLoading(false);
                            });
                            messageContainer.addSuccessMessage({
                                'message': message
                            });
                           totals.isLoading(true);


                        }
                    }
            });
           return true;
        } 

    });
});

in this code, I'm reloading the payment method when ajax request is succeeded.

Main part of the code for reloading payment info:

getPaymentInformationAction(deferred);
jQuery.when(deferred).done(function () {
    isApplied(false);
    totals.isLoading(false);
});
5
  • welcome buddy :-)
    – Manish Joy
    Feb 20, 2017 at 6:51
  • Below js was not working for me ...can u hlep me
    – Mahi M
    Apr 24, 2018 at 11:49
  • I have refresh the payment section as per your code, But I wish to unset the selected paymnet method before refreshing payment section
    – Jaisa
    Jun 8, 2018 at 14:10
  • I have tried quote.setPaymnetMethod(null) . It unsets the selected paymnet section, but after refreshing payment section it sets the selected paymnet method again. Please provide me a solution
    – Jaisa
    Jun 8, 2018 at 14:13
  • totals is undefined . Who is totals ? Oct 7, 2022 at 9:56

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.