Developer forum

Forum » Development » Proceed to next step in cart

Proceed to next step in cart

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

Is there a way to programmatically load the next step of the cart? I have a custom field called "Is Quote" that a user can set on the first step. If the order is a quote indeed, I would like to skip the step for payment and shipping.

Thanks,

Imar


Replies

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Hi Imar,

You can make a notification subscriber that listens for the BeforeRenderingNewStep notification and tell the args object that you want to redirect to a different step.

Something like this

[Subscribe(Dynamicweb.Notifications.eCommerce.Cart.BeforeRenderingNewStep)]
public class NewStepObserver : NotificationSubscriber
{
	public override void OnNotify(string notification, NotificationArgs args)
	{
		var stepArgs = args as Dynamicweb.Notifications.eCommerce.Cart.BeforeRenderingNewStepArgs;

		stepArgs.RedirectToStepIndex = true;
		stepArgs.StepIndex = 4; //Or whatever step you want to go to
	}
}

Note, you still need to be able to pass the step validation. That is, for Order.Complete = false, you can only go to (and including) the checkout step. For Order.Complete = true, you can only move between steps after the checkout step.

- Jeppe

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Also, remember that the step indexes are 0-based.

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Beautiful, that looks great. Second time today you are saving me..... ;-)

Will try it out and report back.

Imar

 

You must be logged in to post in the forum