Set<CartItem> cartItems = cart.getCartItems();
Set<OrderItem> orderItems = new HashSet<OrderItem>();
for (Iterator<CartItem> iteratorCartItem = cartItems.iterator(); iteratorCartItem.hasNext();) {
CartItem cartItem = (CartItem) iteratorCartItem.next();
OrderItem orderItem = new OrderItem();
orderItem.setCurrency(cart.getCurrency());
orderItem.setProductSkuCode(cartItem.getProductSkuCode());
orderItem.setProductSku(cartItem.getProductSku());
orderItem.setPrice(cartItem.getPrice(cart.getMarketAreaId(), cart.getRetailerId()).getSalePrice());
orderItem.setQuantity(cartItem.getQuantity());
// TAXES
Set<CartItemTax> taxes = cartItem.getTaxes();
if(taxes != null){
for (Iterator<CartItemTax> iteratorCartItemTax = taxes.iterator(); iteratorCartItemTax.hasNext();) {
CartItemTax cartItemTax = (CartItemTax) iteratorCartItemTax.next();
OrderTax orderTax = new OrderTax();
orderTax.setName(cartItemTax.getTax().getName());
orderTax.setPercent(cartItemTax.getTax().getPercent());
orderTax.setAmount(cartItemTax.getTaxAmount());
orderItem.getOrderTaxes().add(orderTax);
}
}
orderItems.add(orderItem);
}