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

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

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);
});
  • welcome buddy :-) – Manish Joy Feb 20 '17 at 6:51
  • Below js was not working for me ...can u hlep me – Mano M Apr 24 '18 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 '18 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 '18 at 14:13

Your Answer

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

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