Developer forum

Forum » Integration » Cannot alter order after visiting checkout page

Cannot alter order after visiting checkout page

Unnsteinn Garðarsson
Unnsteinn Garðarsson
Reply

Hello, I am having a problem that I suspect is related to some logic in the DW code. My scenario is as follows.

1. I open the page that renders the information step of the cart app. The user is allowed to add items to the cart in this step, for each orderline the user can select how many of them he wants to gift wrap, this number is accumulated and sent to our ERP system which returns another orderline item that represents the gift wrap and a correct quantity. I can to back from the information step and visit it again and increment/decrement gift wraps for individual orderlines, recalculate and everything works fine.

2. Then I continue to the checkout step of the cart.

3. Now I go back to the information step and I want to increment/decrement gift wraps for some items, the same request is sent to our ERP system, the same response is received and the order is identical in the CardLoaded subscriber, however when I examine the order and orderlines in the OrderTemplateExtender and the OrderLineTemplateExtender, this new orderline item is missing.

4. Now if I go back to the home page and add another item in the cart and proceed again to the information step of the cart I can see the gift wrap item, the quantity of it matches the quantity I selected in the first place but it cannot be altered.

Any ideas on why this might be happening and how I can find a workaround for it is highly appreciated.

Edit:

I notice that there is a flag called isCartEditable and it is set to true when examining the object in the CartLoaded subscriber after navigating back from the checkout step. The main difference between the object now is that it has become an order and is not a cart anymore.

I have also tried to use the OrderService method DowngradeToCart for when I am returning to the information step but that gives me this error

This is the code


OrderService orderService = new OrderService();
orderService.DowngradeToCart(order);
orderService.Save(order);

Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply
This post has been marked as an answer

Hi Unnsteinn,

try this code instead:
                        Services.Orders.DowngradeToCart(order);
                        Common.Context.SetCart(order);                        
                        order.CartV2StepIndex = 0;
                        Services.Orders.Save(order);

Kind regards, Dmitrij

Votes for this answer: 2

 

You must be logged in to post in the forum