Site structure
Version 5.x > Site structure > Shopping Cart Step Problem View modes: 
User avatar
Member
Member
vivianferguson685-hotmail - 9/24/2010 11:38:29 AM
   
Shopping Cart Step Problem
Hi There, firstly, sorry if this is in the wrong section. In a rush so if its in the wrong area can an admin move it please?

The main problem is I am using a shopping cart and all that simply needs to happen is for a step to be skipped under a certain condition:

protected void Page_Load(object sender, EventArgs e)
{
bool isMed = false;
foreach (ShoppingCartItemInfo item in ShoppingCartInfoObj.CartItems)
{
if (item.SKUObj != null)
{
isMed = ValidationHelper.GetBoolean(item.SKUObj.GetValue("SKUIsPMed"), false);
if (isMed)
{
//ShoppingCartStep ctrl = (ShoppingCartStep)this.Page.LoadControl("~/cmstemplates/website/usercontrols/checkout/PharmacyQuestions.ascx");
//this.ShoppingCartControl.LoadStep(ctrl);

this.ShoppingCartControl.NextStepIndex = 5;
base.ButtonNextClickAction();
}
}
}

As you can see in the if, I have tried one way of skipping, but it says that the load control bit has no value? Any ideas?

Just below that is the other method I am trying in order to skip a step in the shopping cart procress and it is throwing a null exeception also. The step is cleared and then the current step is loaded into the panel as you can see from the code below.

It works perfectly fine if you click the next or back buttons normally, but when i programatically try to skip the step the pnlCartStepInner.Controls.Add(this.CurrentStepControl); bit throws an error.

// Display current control
pnlCartStepInner.Controls.Clear();
pnlCartStepInner.Controls.Add(this.CurrentStepControl);

Sorry if this isn't very clear, I hope I've given you enough infromation as these are the points where the code is erroring.

Has anyone out there tried to skip a step in the shopping cart process?

Many Thanks,
Vivian

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 10/8/2010 2:52:25 AM
   
RE:Shopping Cart Step Problem
Hello,


could you please follow these instructions? Developing custom dialogs for the checkout process. Remove the unwanted code from the sample but preserve the methods.

I hope it will help you.


Best regards,
Helena Grulichova

User avatar
Member
Member
DesignByOnyx - 12/6/2010 6:24:36 PM
   
RE:Shopping Cart Step Problem
Hey, I had this same problem, and it was a tricky work-around. I have to admit that the ecommerce extensibility is less than elegant. A few minor changes in the core architecture of the eccommerce module would allow for great flexibility... maybe in Versions 6.

If I remember correctly, you have to add some logic to the "ProcessStep" method in each of the checkout steps. In my specific situation, I wanted to skip the "Payment Selection" step if there was only ONE to choose from. Make sense? For example, I was ONLY using Authorize.NET... so I didn't want users to have to select it. Here is the logic I used at the end of ProcessStep for OrderAddresses:

Take special note of how I increment the CurrentStepIndex at the end. I am also setting a custom variable SINGLE_PAYMENT_OPTION for use in other parts of the checkout... for example. Lets say someone enters their address and clicks next... my code checks to see if there is only one payment option. If so, update the cart accordingly and skip the Payment Selection. Then, if the user wishes to click BACK, I must then check for the value of SINGLE_PAYMENT_OPTION... and skip the step again so that they return to the Addresses step. Does that make sense? Hope this helps.

// Check Payment options and skip if only one exists

int siteId = CMSContext.CurrentSite.SiteID;

DataSet po = PaymentOptionInfoProvider.GetAllPaymentsForSite(siteId, StatusEnum.Enabled);
if (!DataHelper.DataSourceIsEmpty(po) && DataHelper.GetItemsCount(po) == 1)
{
this.ShoppingCartControl.SetTempValue(SINGLE_PAYMENT_OPTION, true);

int paymentOptionID = ValidationHelper.GetInteger(po.Tables[0].Rows[0]["PaymentOptionID"], 0);

ShoppingCartInfoObj.ShoppingCartPaymentOptionID = paymentOptionID;

this.ShoppingCartControl.CurrentStepIndex += 1;
}

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 12/7/2010 1:26:15 AM
   
RE:Shopping Cart Step Problem
Hi,


Thank you for your code.

In fact, we will improve the e-commerce module in the version 6.0. I hope you will be more satisfied.


Best regards,
Helena Grulichova


User avatar
Member
Member
RobJeremy - 2/2/2014 2:06:22 PM
   
RE:Shopping Cart Step Problem
Hey everyone.

I don't have any problems or questions on this topic, but I had found this thread on the devnet to be quiet useful, and would like to add to it.

If you are looking to "jump to a different step" in the shopping cart on page load, you could easily add this code before the LoadCurrentStep() function is called on Page_Load of the ShoppingCart.ascx.cs control.


//if this user has Session["cartCheckoutStep2"] set as "moveStep3", we need to send them to step 3
if (!String.IsNullOrEmpty(Session["cartCheckoutStep2"] as string))
{
//this condition could be anything
if (Session["cartCheckoutStep2"] == "moveStep3")
{
//increment the step index to be Step 3 before function below is called
CurrentStepIndex = 2;
}
}
// Display / hide checkout process images
plcCheckoutProcess.Visible = DisplayStepImages;

// Load current step data
LoadCurrentStep();