use of org.broadleafcommerce.core.promotionMessage.service.PromotionMessageGenerator in project BroadleafCommerce by BroadleafCommerce.
the class CartMessageOrderItemServiceExtensionHandler method gatherProductCartMessages.
protected List<String> gatherProductCartMessages(OrderItem orderItem) {
List<String> cartMessages = new ArrayList<>();
if (DiscreteOrderItem.class.isAssignableFrom(orderItem.getClass())) {
DiscreteOrderItem discreteOrderItem = (DiscreteOrderItem) orderItem;
Product product = discreteOrderItem.getProduct();
for (PromotionMessageGenerator generator : generators) {
Map<String, List<PromotionMessageDTO>> promotionMessages = generator.generatePromotionMessages(product);
List<PromotionMessageDTO> messageDTOs = new ArrayList<>();
addPromotionMessagesForType(messageDTOs, promotionMessages.get(PromotionMessagePlacementType.CART.getType()));
addPromotionMessagesForType(messageDTOs, promotionMessages.get(PromotionMessagePlacementType.EVERYWHERE.getType()));
BLCPromotionMessageUtils.sortMessagesByPriority(messageDTOs);
cartMessages.addAll(BLCPromotionMessageUtils.gatherMessagesFromDTOs(messageDTOs));
}
}
return cartMessages;
}
use of org.broadleafcommerce.core.promotionMessage.service.PromotionMessageGenerator in project BroadleafCommerce by BroadleafCommerce.
the class PromotionMessageVariableExpression method getProductPromotionMessages.
public List<PromotionMessageDTO> getProductPromotionMessages(Product product, String... placements) {
List<String> filteredPlacements = filterInvalidPlacements(placements);
if (!filteredPlacements.contains(PromotionMessagePlacementType.EVERYWHERE.getType())) {
filteredPlacements.add(PromotionMessagePlacementType.EVERYWHERE.getType());
}
Map<String, List<PromotionMessageDTO>> promotionMessages = new MultiValueMap();
for (PromotionMessageGenerator generator : generators) {
promotionMessages.putAll(generator.generatePromotionMessages(product));
}
List<PromotionMessageDTO> filteredMessages = BLCPromotionMessageUtils.filterPromotionMessageDTOsByTypes(promotionMessages, filteredPlacements);
BLCPromotionMessageUtils.sortMessagesByPriority(filteredMessages);
return filteredMessages;
}
Aggregations