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.
-
Can describe using which method you added checkbox there in payment section?– Dhiren VasoyaCommented Feb 17, 2017 at 13:11
-
its done by overriding , checkout_index_index.xml and then put your js and html to show checkbox– Faisal KazmiCommented Feb 19, 2017 at 17:54
-
Can you please share your full code here, I have same requirement.– Suresh ChikaniCommented Nov 13, 2017 at 10:51
Add a comment
|
1 Answer
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);
});
-
-
-
I have refresh the payment section as per your code, But I wish to unset the selected paymnet method before refreshing payment section– JaisaCommented 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– JaisaCommented Jun 8, 2018 at 14:13
-