Add ‘OrderWizard.Module.PaymentMethod.Selector’ as dependency to the entry point file. Extend ‘OrderWizardModulePaymentMethodSelector.prototype’ and use wrap function to keep the already existing properties and functions. Check whether the customer has terms by retrieving the payment terms from his profile. Use ‘setModuleByType()’ function to set the invoice as default payment option.
if (!this.selectedModule) {
let selected_type;
if(this.wizard.options.profile.get(‘paymentterms’)){
selected_type = ‘invoice’;
}
this.setModuleByType(selected_type, true);
}
If want to set ‘invoice’ payment option as default for those having specific terms, then add a condition to check for those specific terms.
if (!this.selectedModule) {
let selected_type;
if(this.wizard.options.profile.get(‘paymentterms’)){
if(this.wizard.options.profile.get(‘paymentterms’)[‘internalid’] === ‘2’){
selected_type = ‘invoice’;
}
}
this.setModuleByType(selected_type, true);
}