We can solve this by extending the profile model under SuiteScript and adding certain codes.
For showing the invoice section on payment method section, here we have implemented the vinson related code in our file. Here, the related view is payment method selector
OrderWizardModulePaymentMethodSelector.prototype.initialize = function initialize(options) {
WizardModule.prototype.initialize.apply(this, arguments);
console.log('this132132',this);
this.modules = [
{
classModule: OrderWizardModulePaymentMethodCreditcard
, name: _('Credit / Debit Card').translate()
, type: 'creditcard'
, options: {}
}
, {
classModule: OrderWizardModulePaymentMethodInvoice
, name: _('Invoice').translate()
, type: 'invoice'
, options: {}
}
, {
classModule: OrderWizardModulePaymentMethodPayPal
, name: _('PayPal').translate()
, type: 'paypal'
, options: {}
}
];
var self = this, customizeModule = [];
var firstModuleToShow = 'creditcard';
var paymentTerms = profile.get('paymentterms') ? profile.get('paymentterms').internalid : SC.CONFIGURATION.get('micrositeSolution.siteTerms');
console.log('paymentterms',paymentTerms);
jQuery.when(Helper.setMicroSiteInfo()).done(function whenDone(response) {
var siteTermsRestriction = SC.CONFIGURATION.get('micrositeSolution.siteTermsRestriction');
var hasInvoiceRestriction = _.contains(siteTermsRestriction, paymentTerms);
_.each(self.modules, function eachPaymentModule(module) {
if (module.type == 'creditcard' && response.siteCreditCard == 'T') {
firstModuleToShow = 'creditcard';
customizeModule.push(module);
}
if (module.type == 'invoice' && response.siteInvoice == 'T') {
if (self.modules.length > 0) {
firstModuleToShow = 'creditcard';
} else {
firstModuleToShow = 'invoice';
}
if (!hasInvoiceRestriction) {
customizeModule.push(module);
}
}
if (module.type == 'paypal' && response.sitePaypal == 'T') {
firstModuleToShow = 'paypal';
customizeModule.push(module);
}
});
self.modules = customizeModule;
self.setModuleByType(firstModuleToShow);
self.render();
});
if (!options.disableExternalPaymentMethods)
{
var payment_methods = Configuration.get('siteSettings.paymentmethods', [])
, payment_methods_configuration = Configuration.get('paymentmethods', [])
, external_payment_methods = _.where(payment_methods, {isexternal: 'T'});
_.each(external_payment_methods, function (payment_method)
{
var payment_method_configuration = _.find(payment_methods_configuration, {key: payment_method.key});
self.modules.push(
self.getExternalPaymentMethodModule(payment_method, options, payment_method_configuration)
);
});
this.wizard.model.on('change:confirmation', function (model, confirmation)
{
if (confirmation && confirmation.statuscode === 'redirect')
{
window.location.href = _.addParamsToUrl(confirmation.redirecturl, {touchpoint: Configuration.get('currentTouchpoint')});
throw new Error('This is not an error. This is just to abort javascript');
}
});
}
_.each(this.modules, function (module)
{
var ModuleClass = module.classModule;
module.instance = new ModuleClass(_.extend({
wizard: self.wizard
, step: self.step
, stepGroup: self.stepGroup
}, module.options));
module.instance.on('ready', function (is_ready)
{
self.moduleReady(is_ready);
});
});
};
Another code we have used is for render function()
OrderWizardModulePaymentMethodSelector.prototype.render = function render() {
if (this.wizard.hidePayment()) {
this.$el.empty();
this.trigger('change_label_continue');
return;
}
if (!this.selectedModule) {
var selected_payment = this.model.get('paymentmethods').findWhere({primary: true})
, selected_type;
if (selected_payment) {
selected_type = selected_payment.get('type');
} else if (this.wizard.options.profile.get('paymentterms')) {
selected_type = 'invoice';
}
this.setModuleByType(selected_type, true);
} else if (this.selectedModule.type === 'paypal' && !this.model.get('isPaypalComplete')) {
this.trigger('change_label_continue', _('Continue to Paypal').translate());
} else {
this.trigger('change_label_continue');
}
// We do this here so we give time for information to be bootstrapped
// Forcing all the module to be active and then lets the microsite decide which module should be shown
_.each(this.modules, function (module) {
module.isActive = true
});
// console.log('Modules1',this.modules);
this._render();
if (_.getParameterByName(window.location.href, 'externalPayment') === 'FAIL' && this.showExternalPaymentErrorMessage) {
this.showExternalPaymentErrorMessage = false;
this.manageError(this.externalPaymentErrorMessage);
}
var self = this;
_.each(this.modules, function (module) {
if (module.isSelected)
{
module.instance.isReady = false;
module.instance.render();
self.$('#payment-method-selector-content').empty().append(module.instance.$el);
}
});
};