Search in sources :

Example 1 with OrderItemHolder

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

the class ItemOfferProcessorImpl method markRelatedQualifiersAndTargets.

/**
 * When the {@link Offer#getRequiresRelatedTargetAndQualifiers()} flag is set to true, we must make sure that we
 * identify qualifiers and targets together, as they must be related to each other based on the
 * {@link OrderItem#getParentOrderItem()} / {@link OrderItem#getChildOrderItems()} attributes.
 *
 * @param itemOffer
 * @param order
 * @return whether or not a suitable qualifier/target pair was found and marked
 */
protected boolean markRelatedQualifiersAndTargets(PromotableCandidateItemOffer itemOffer, PromotableOrder order) {
    OrderItemHolder orderItemHolder = new OrderItemHolder(null);
    for (Entry<OfferItemCriteria, List<PromotableOrderItem>> entry : itemOffer.getCandidateQualifiersMap().entrySet()) {
        OfferItemCriteria itemCriteria = entry.getKey();
        List<PromotableOrderItem> promotableItems = entry.getValue();
        List<PromotableOrderItemPriceDetail> priceDetails = buildPriceDetailListFromOrderItems(promotableItems);
        int qualifierQtyNeeded = offerServiceUtilities.markRelatedQualifiersAndTargetsForItemCriteria(itemOffer, order, orderItemHolder, itemCriteria, priceDetails, this);
        if (qualifierQtyNeeded != 0) {
            return false;
        }
    }
    return markTargets(itemOffer, order, orderItemHolder.getOrderItem(), false);
}
Also used : OfferItemCriteria(org.broadleafcommerce.core.offer.domain.OfferItemCriteria) ArrayList(java.util.ArrayList) List(java.util.List) OrderItemHolder(org.broadleafcommerce.core.order.domain.dto.OrderItemHolder) PromotableOrderItem(org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderItem) PromotableOrderItemPriceDetail(org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderItemPriceDetail)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 OfferItemCriteria (org.broadleafcommerce.core.offer.domain.OfferItemCriteria)1 PromotableOrderItem (org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderItem)1 PromotableOrderItemPriceDetail (org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderItemPriceDetail)1 OrderItemHolder (org.broadleafcommerce.core.order.domain.dto.OrderItemHolder)1