What must be going wrong here?
# suitecommerce
v
What must be going wrong here?
s
Does the view you're adding to extend the wizard module?
v
yes it does
s
Can you share your code?
v
sure
Copy code
Checkout.addToViewContextDefinition('OrderWizard.Module.PaymentMethod.Selector', 'activeModules', 'array', function(context) {
					var newActiveModules = [];

					for(var i = 0; i < context.activeModules.length; i++) {
						if(context.activeModules[i].type == "invoice") {
							continue;
						} else {
							newActiveModules.push(context.activeModules[i]);
						}
					}

					context.newLength = newActiveModules.length;

					return newActiveModules;
				});
I'm trying to remove the 'Invoice' option from the checkout step via an extension. We want to use Invoicing elsewhere in our solution but not give that as an option to the users when they checkout.
s
Hmm. If it works locally but not remotely, my gut is that execution order is coming in to play, so you may have to execute this after the module has loaded. For example, add an event to run this code beforeShowContent
v
Okay, I will try that
s
Or you can try using the Layout component instead
If you're just manipulating a view's context, that should also work. You sometimes get the "is not valid for the current component" error when it can't find the view in its child view chain
v
Yes, I was getting that error when I tried to use Layout, so I switched to using Checkout instead.
s
I have found the Layout component more reliable in circumstances where contextual data of a specific component is not required
Interesting, OK. Try adding an event, and try a couple of different ones if beforeShowContent doesn't work. Like beforeAppendView
v
Okay, so add an event for Checkout and then use Layout to manipulate the context?
s
Well I would try them individually first
v
Ok. I will do that. I'll let you know which one worked for me.
s
Oh and you can also try changing the 'array' option to 'string'. I have a feeling that 'array' might not be a valid type
v
I tried using Layout and Checkout with the events beforeShowContent and beforeAppendView In the case of beforeShowContent, it still throws the same error In the case of beforeAppendView, it doesn't throw any error, but it does not manipulate the context variable. I also switched from 'array' to 'string' and then 'object' but it doesn't help as well.
Copy code
Checkout.on("afterShowContent", function() {
					jQuery(".order-wizard-paymentmethod-selector-module-button").each(function() {
						if(jQuery(this).attr('value') == 'invoice') {
							jQuery(this).remove();
						}
					});
				});
I tried this with jQuery, and it works, but I'm not sure if it is the right way to go.
s
Well, it's disappointing you couldn't get it t o work the other way. jQuery is a somewhat inelegant solution, but we use it too sometimes.
v
I guess it will have to be jQuery for now. I'll keep trying the other way though, that would be a more solid solution.
Thank you for your assistance. 🙂