Developer forum

Forum » Development » My cart is emptied when I reach checkout in CartV2

My cart is emptied when I reach checkout in CartV2

Martin Slot
Reply
Hello

I have a bit of a problem, when I reach the checout step, my cart is emptied, I integrate with an unsupported gateway provider and before sending the user to this provider, the user is presented to a view, where the user clicks a button and is then send to the provder. But on this step the cart is emptied and this is misleading the customer.
My StartCheckout function holds this code:

       public override string StartCheckout(Dynamicweb.eCommerce.Orders.Order order)
        {
            LogEvent(order, "Starter checkout til RBS");

            XMLOrder orderXml = new XMLOrder("dk", "");

            string resultXml = orderXml.CreateXML(order);
            LogEvent(order, "Result XML: " + resultXml);

            string callbackUrl = CreateCallbackUrl(order);
            LogEvent(order, "Callback URL: " + callbackUrl);
            string urlToPaymentGateway = String.Empty;
            try
            {
                urlToPaymentGateway = orderXml.SendXML(resultXml, order.ID, callbackUrl);
            }
            catch (Exception e)
            {
                LogError(order, e.Message + "<br/>" + e.StackTrace + "<br/>" + e.TargetSite);
            }

            LogEvent(order, "URL til payment gateway: " + urlToPaymentGateway);

            return PrintShowPaymentMethodsTemplate(order, urlToPaymentGateway);
        }
The PrintShowPaymentMethodTemplate function holds this:
        private string PrintShowPaymentMethodsTemplate(Dynamicweb.eCommerce.Orders.Order order, string urlToPaymentGateway)
        {
            Dynamicweb.Templatev2.Template template = new Dynamicweb.Templatev2.Template("./RBS/ShowPaymentMethodsTemplate.html");

            template.SetTag("url", urlToPaymentGateway);

            return template.Output();
        }


Is there any way that I can stop the cart from being emptied when showing thix final template to the user?

Replies

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Hi Martin

This is correct and expected behavior. If you check chapter section 1.3 point 2 of the Checkout Handler documentation, you'll see that the order is removed from the session and only exists as the object passed to you in the StartCheckout method. If you need the order to be rendered to the user, then you need to render it explicitly.

- Jeppe

 
Martin Slot
Reply
This post has been marked as an answer
Ah ok thanks. I have acctually read this, but I thought that it meant that it first was removed when the session when the gateway took over. How do I render it then? I am not much a DW frontender.
Votes for this answer: 0
 
Martin Slot
Reply
Ah I understand. You are telling me that I have to render/show it for the user.

 

You must be logged in to post in the forum