try {
//We allow product options to be submitted via form post or via query params. We need to take
//the product options and build a map with them...
HashMap<String, String> productOptions = getOptions(uriInfo);
OrderItemRequestDTO orderItemRequestDTO = new OrderItemRequestDTO();
orderItemRequestDTO.setProductId(productId);
orderItemRequestDTO.setCategoryId(categoryId);
orderItemRequestDTO.setQuantity(quantity);
//If we have product options set them on the DTO
if (productOptions.size() > 0) {
orderItemRequestDTO.setItemAttributes(productOptions);
}
Order order = orderService.addItem(cart.getId(), orderItemRequestDTO, priceOrder);
order = orderService.save(order, priceOrder);