Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > Skip a shopping cart step View modes: 
User avatar
Certified Developer v7
Certified  Developer v7
slycknick - 10/28/2009 8:29:11 AM
   
Skip a shopping cart step
I've found examples of how to add a shopping cart step but what I want to do is skip a step depending on certain conditions.

In particular I want to skip the registration step if the user is already a customer and logged in.

I've had a go but failed to succeed. Has anyone managed this?

Nick

User avatar
Kentico Support
Kentico Support
kentico_radekm - 11/10/2009 9:29:32 AM
   
RE:Skip a shopping cart step
Hello Nick.

You can skip some shopping process step by loading a different step, using this API:

// Load extra step
// in standard checkout process definition
ShoppingCartStep ctrl =
(ShoppingCartStep)this.Page.LoadControl("~/CMSEcommerce/ShoppingCart /MyVipStep.ascx");
this.ShoppingCartControl.LoadStep(ctrl);

You can, of course, put this piece of code into if - then statement. Here is an example how to skip (load) some particular step in dependance on currect user´s role: http://devnet.kentico.com/docs/ecommerceguide/developing_custom_dialogs_for_checkout.htm

Best Regards,
Radek Macalik
Support Engineer

User avatar
Certified Developer v7
Certified  Developer v7
slycknick - 11/10/2009 10:21:59 AM
   
RE:Skip a shopping cart step
Thanks for the response.
After some playing around I found if I just increment the NextStepIndex and then call the base routine it did what I wanted.

Nick


public override void ButtonNextClickAction()
{


// If customer is registered
if ((!this.ShoppingCartControl.IsInternalOrder) && (this.ShoppingCartInfoObj.CustomerInfoObj != null))
{

if (IsValid() && ProcessStep())
{
try
{
// Skip registration
this.ShoppingCartControl.NextStepIndex = 2;
base.ButtonNextClickAction();
}

catch
{
// Error while loading extra step control -> Do standard action
base.ButtonNextClickAction();
}
}

}

else
{

// Do standard action (validate step data, process step data, load next step)

base.ButtonNextClickAction();

}

}

User avatar
Kentico Support
Kentico Support
kentico_radekm - 11/12/2009 2:32:30 PM
   
RE:Skip a shopping cart step
Hello Nick.

Thank you for posted here a solution. I believe it can be useful also for other users.

Best Regards,
Radek Macalik
Support Engineer