Hi Chu,
Yes, product options are stored as Order Items and they have a reference to main order item. You can check this directly in the database in the COM_OrderItem you will see OrderItemGuid and OrderItemParentGuid:
- If OrderItemParentGuid is null - it is your main order item
- If OrderItemParentGuid is NOT empty - this is a product option assigned to the order item
Also, there is another column called OrderItemSKUID which is a reference to COM_SKU table where products AND product options are stored.
So you can amend your code to something like:
var items = OrderItemInfoProvider.GetOrderItems(order.OrderID);
foreach (var orderItem in items.Where(x => x.OrderItemParentGUID == Guid.Empty))
{
// do something with order item
foreach (var orderItemOption in items.Where(x => x.OrderItemParentGUID == orderItem.OrderItemGUID))
{
// do something with order item option
var text = orderItemOption.OrderItemText;
}
}