Search in sources :

Example 6 with DiscreteOrderItemRequest

use of org.broadleafcommerce.core.order.service.call.DiscreteOrderItemRequest in project BroadleafCommerce by BroadleafCommerce.

the class OrderItemServiceImpl method createBundleOrderItem.

@Override
public BundleOrderItem createBundleOrderItem(final BundleOrderItemRequest itemRequest) {
    final BundleOrderItem item = (BundleOrderItem) orderItemDao.create(OrderItemType.BUNDLE);
    item.setQuantity(itemRequest.getQuantity());
    item.setCategory(itemRequest.getCategory());
    item.setName(itemRequest.getName());
    item.setBundleOrderItemFeePrices(itemRequest.getBundleOrderItemFeePrices());
    item.setOrder(itemRequest.getOrder());
    if (itemRequest.getSalePriceOverride() != null) {
        item.setSalePriceOverride(Boolean.TRUE);
        item.setSalePrice(itemRequest.getSalePriceOverride());
        item.setBaseSalePrice(itemRequest.getSalePriceOverride());
    }
    if (itemRequest.getRetailPriceOverride() != null) {
        item.setRetailPriceOverride(Boolean.TRUE);
        item.setRetailPrice(itemRequest.getRetailPriceOverride());
        item.setBaseRetailPrice(itemRequest.getRetailPriceOverride());
    }
    for (DiscreteOrderItemRequest discreteItemRequest : itemRequest.getDiscreteOrderItems()) {
        discreteItemRequest.setBundleOrderItem(item);
        DiscreteOrderItem discreteOrderItem;
        if (discreteItemRequest instanceof GiftWrapOrderItemRequest) {
            discreteOrderItem = createGiftWrapOrderItem((GiftWrapOrderItemRequest) discreteItemRequest);
        } else {
            discreteOrderItem = createDiscreteOrderItem(discreteItemRequest);
        }
        item.getDiscreteOrderItems().add(discreteOrderItem);
    }
    applyAdditionalOrderItemProperties(item);
    return item;
}
Also used : DiscreteOrderItem(org.broadleafcommerce.core.order.domain.DiscreteOrderItem) BundleOrderItem(org.broadleafcommerce.core.order.domain.BundleOrderItem) DiscreteOrderItemRequest(org.broadleafcommerce.core.order.service.call.DiscreteOrderItemRequest) GiftWrapOrderItemRequest(org.broadleafcommerce.core.order.service.call.GiftWrapOrderItemRequest)

Aggregations

DiscreteOrderItemRequest (org.broadleafcommerce.core.order.service.call.DiscreteOrderItemRequest)6 BundleOrderItem (org.broadleafcommerce.core.order.domain.BundleOrderItem)3 DiscreteOrderItem (org.broadleafcommerce.core.order.domain.DiscreteOrderItem)3 Category (org.broadleafcommerce.core.catalog.domain.Category)2 Product (org.broadleafcommerce.core.catalog.domain.Product)2 ProductBundle (org.broadleafcommerce.core.catalog.domain.ProductBundle)2 Sku (org.broadleafcommerce.core.catalog.domain.Sku)2 GiftWrapOrderItemRequest (org.broadleafcommerce.core.order.service.call.GiftWrapOrderItemRequest)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 SkuBundleItem (org.broadleafcommerce.core.catalog.domain.SkuBundleItem)1 GiftWrapOrderItem (org.broadleafcommerce.core.order.domain.GiftWrapOrderItem)1 Order (org.broadleafcommerce.core.order.domain.Order)1 OrderItem (org.broadleafcommerce.core.order.domain.OrderItem)1 PersonalMessage (org.broadleafcommerce.core.order.domain.PersonalMessage)1 AbstractOrderItemRequest (org.broadleafcommerce.core.order.service.call.AbstractOrderItemRequest)1 BundleOrderItemRequest (org.broadleafcommerce.core.order.service.call.BundleOrderItemRequest)1 ConfigurableOrderItemRequest (org.broadleafcommerce.core.order.service.call.ConfigurableOrderItemRequest)1 NonDiscreteOrderItemRequestDTO (org.broadleafcommerce.core.order.service.call.NonDiscreteOrderItemRequestDTO)1 OrderItemRequest (org.broadleafcommerce.core.order.service.call.OrderItemRequest)1 OrderItemRequestDTO (org.broadleafcommerce.core.order.service.call.OrderItemRequestDTO)1