Search in sources :

Example 1 with GiftWrapOrderItemRequest

use of org.broadleafcommerce.core.order.service.call.GiftWrapOrderItemRequest 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

BundleOrderItem (org.broadleafcommerce.core.order.domain.BundleOrderItem)1 DiscreteOrderItem (org.broadleafcommerce.core.order.domain.DiscreteOrderItem)1 DiscreteOrderItemRequest (org.broadleafcommerce.core.order.service.call.DiscreteOrderItemRequest)1 GiftWrapOrderItemRequest (org.broadleafcommerce.core.order.service.call.GiftWrapOrderItemRequest)1