Disable Order summary continue button in Check out page when invoice orders terms are “Prepayment”.

When a customer’s terms are prepayment and they try to make an order using an invoice, the order must be denied. Along with that order summary continue button in checkout page is also denied for further process .For this, we can disable the continue button and display a message regarding this.

	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 ordersummarystepbuttoncontinue = $(".order-summary-step-button-continue");
								var paymentoptiontermsterms = this.profile.attributes.paymentterms.name;
								// Strict equality to avoid pitfalls of type coercion
								if (paymentOption === "invoice" && paymentoptiontermsterms === "Prepayment") {
									continueButton.prop('disabled', true);
									ordersummarystepbuttoncontinue.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);
									ordersummarystepbuttoncontinue.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) { 
								console.error('error at showbilling', e);
							}
						},

Leave a comment

Your email address will not be published. Required fields are marked *