When a customer’s terms are prepayment and they try to make an order using an invoice, the order must be denied. For this, we can disable the continue button and display a message regarding this.
// code for Payment Method Continue Button//
showBilling: function showBilling(event) {
// Payment Method Continue Button
var checkOutStep = event.target.getAttribute('step')
document.cookie = "step=" + checkOutStep + ';path=/';
var url = new URL(window.location.href);
url.searchParams.set('step', checkOutStep);
window.history.replaceState(null, null, url);
// payment method invoice option terms are prepayment
try{
var paymentOption = $('[data-action="select-payment-method"]').val();
var continueButton = $('#payment_method_continue_button');
var paymentoptiontermsterms = this.profile.attributes.paymentterms.name;
// Strict equality to avoid pitfalls of type coercion
if ( (paymentOption === "invoice" && paymentoptiontermsterms === "Prepayment")) {
continueButton.prop('disabled', true);
var global_view_message = '<span class="global-views-message global-views-message-error alert">Please select other payment method </span>'
$(global_view_message).insertAfter('[data-action="select-payment-method"]');
} else {
continueButton.prop('disabled', false);
if (checkOutStep == 3) {
console.log('PaymentContinue', checkOutStep)
this.wizard.selectedShipping = true;
this.wizard.selectedDelivery = true;
this.wizard.selectedPayment = true;
this.wizard.selectedBilling = true;
$(".billing_class").removeClass("close_section");
}
$("html, body").animate({
scrollTop: $('#payment_method_continue_button').offset().top - 70
}, 10);
}
}
catch(e) { }
},
