Looping through CartItems

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 年 前
Hey
Thanks for a great product. I need to connect nopCommerce to our internal ordersystem and do not know how to loop though the CartItems in c#.

I get the order number and from that point I need directions on how to grab the order and loop through the items in that particular order to store that in our internal system.

Please help.
14 年 前
Poke around Libraries > Nop.BusinesLogic > Orders

Specifically: GetOrderProductVariantsByOrderID()

This method takes the OrderID and returns an OrderProductVariantCollection (these are the line items). You can then iterate through the OrderProductVariants and do what you need.

Some pseudo code:

OrderProductVariantColletion orderProductVariants = OrderManager.GetOrderProductVariantsByOrderID(orderID);

foreach (OrderProductVariant opv in orderProductVariants) {
   productVariantID = opv.ProductVariantID;
   quantity = opv.Quantity;
   unitPriceIncludingTax = opv.UnitPriceInclTax;
}

Hope this helps.

C.
14 年 前
Hey
Supergreat! Thanks!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.