Search in sources :

Example 1 with OrderItemContainer

use of org.broadleafcommerce.core.order.domain.OrderItemContainer in project BroadleafCommerce by BroadleafCommerce.

the class PromotableFulfillmentGroupImpl method getDiscountableOrderItems.

@Override
public List<PromotableOrderItem> getDiscountableOrderItems() {
    if (discountableOrderItems != null) {
        return discountableOrderItems;
    }
    discountableOrderItems = new ArrayList<PromotableOrderItem>();
    List<Long> discountableOrderItemIds = new ArrayList<Long>();
    for (FulfillmentGroupItem fgItem : fulfillmentGroup.getFulfillmentGroupItems()) {
        OrderItem orderItem = fgItem.getOrderItem();
        if (orderItem.isDiscountingAllowed()) {
            discountableOrderItemIds.add(fgItem.getOrderItem().getId());
        } else {
            if (orderItem instanceof OrderItemContainer) {
                OrderItemContainer orderItemContainer = (OrderItemContainer) orderItem;
                if (orderItemContainer.getAllowDiscountsOnChildItems()) {
                    for (OrderItem containedOrderItem : orderItemContainer.getOrderItems()) {
                        if (!containedOrderItem.isDiscountingAllowed()) {
                            discountableOrderItemIds.add(containedOrderItem.getId());
                        }
                    }
                }
            }
        }
    }
    for (PromotableOrderItem item : promotableOrder.getDiscountableOrderItems()) {
        if (discountableOrderItemIds.contains(item.getOrderItemId())) {
            discountableOrderItems.add(item);
        }
    }
    return discountableOrderItems;
}
Also used : FulfillmentGroupItem(org.broadleafcommerce.core.order.domain.FulfillmentGroupItem) OrderItem(org.broadleafcommerce.core.order.domain.OrderItem) OrderItemContainer(org.broadleafcommerce.core.order.domain.OrderItemContainer) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 FulfillmentGroupItem (org.broadleafcommerce.core.order.domain.FulfillmentGroupItem)1 OrderItem (org.broadleafcommerce.core.order.domain.OrderItem)1 OrderItemContainer (org.broadleafcommerce.core.order.domain.OrderItemContainer)1