November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Hi,
That's pretty strange. Can you provide a test case to reproduce the bug? We will work on it ASAP.
Regards,
/Q
The code for adding items to the cart is using the old api:
orderForm.LineItems.Add(lineItem1,false);
Note: the flag 'LineItemRollup" is set to false.
Wait ... what... You added the items using old APIs and removed them by the new APIs? No candies for you!
I will try to verify this issue and file a bug when I have time.
Regards,
/Q
Haha, we're slowly moving our code over to the new api, but that is a process that takes time ;) Thanks!
Btw: Adding and removing items in QuickSilver using new api result in the same error ;)
Hi Mari,
You're using old api to add lineitem to OrderForm, so could you try using old api to remove lineitem
OrderForm.RemoveLineItemFromShipments(lineItem1)
Or you could use new api to add lineitem to shipment or remove lineitem from shipment as document you mentioned
//adding var lineItem = orderFactory.CreateLineItem("code"); var shipment = GetFirstShipment(); cart.AddLineItem(shipment, lineItem); //removing cart.GetFirstShipment().Remove(lineItem);
Could you show your code? Or step to reproduce on Quicksilver, we will verify easier.
Sample code to reproduce in QuickSilver (using an existing order). First, add 4 line items of same sku:
var orderRepo = ServiceLocator.Current.GetInstance<IOrderRepository>(); var orderFactory = ServiceLocator.Current.GetInstance<IOrderFactory>(); var orderId = 9; var order = orderRepo.Load<IPurchaseOrder>(orderId); var form = order.GetFirstForm(); var shipment = form.Shipments.First(); var lineItemOne = orderFactory.CreateLineItem("SKU-21320033"); lineItemOne.Quantity = 1; var lineItemTwo = orderFactory.CreateLineItem("SKU-21320033"); lineItemTwo.Quantity = 1; var lineItemThree = orderFactory.CreateLineItem("SKU-21320033"); lineItemThree.Quantity = 1; var lineItemFour = orderFactory.CreateLineItem("SKU-21320033"); lineItemFour.Quantity = 1; shipment.LineItems.Add(lineItemOne); shipment.LineItems.Add(lineItemTwo); shipment.LineItems.Add(lineItemThree); shipment.LineItems.Add(lineItemFour); orderRepo.Save(order);
Next, we try to remove 2 of them:
var orderRepo = ServiceLocator.Current.GetInstance<IOrderRepository>(); var orderId = 9; var order = orderRepo.Load<IPurchaseOrder>(orderId); var form = order.GetFirstForm(); var shipment = form.Shipments.First(); var lineItemsToRemove = shipment.LineItems.Where(l => l.Code == "SKU-21320033").Take(2).ToList(); foreach (var lineItem in lineItemsToRemove) { shipment.LineItems.Remove(lineItem); } orderRepo.Save(order);
Result: Instead of removing 2 items, only 1 is removed. If you try to remove 4, same result: only 1 is removed.
I created a bug for it - will keep you posted when we investigate. Thanks for bringing this into our attention.
/Q
Hi there,
We got this issue before when try to remove line item from the shipment too. It looks similar issue you have.
You can change the code remove line item like that
foreach (var lineItem in giftItems) { shipment.LineItems.Remove(shipment.LineItems.FirstOrDefault(l => l.LineItemId == lineItem.LineItemId)); }
Hope that fix your issue!
/Tuan
Tuan, yes that will work as a temporary workaround until Episerver fixes the bug. Thanks!
Hi,
According to the documentation you can remove line items from a shipment uisng the Remove method:
In my case that is not working.
Let's say I have an order that consists of 4 items of product Y, and I want to remove 2 of them.
What happens is that only 1 gets removed.
Note: In our site we have our line items in a flat structure, this means that for the example order we will have 4 line items for same sku with qantity 1.
I would consider this a bug, do you agree?
What I would like to see in the api is a method like this: