use of org.broadleafcommerce.core.promotionMessage.dto.PromotionMessageDTO 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.dto.PromotionMessageDTO 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;
}
use of org.broadleafcommerce.core.promotionMessage.dto.PromotionMessageDTO in project BroadleafCommerce by BroadleafCommerce.
the class PromotionMessageDTOServiceImpl method convertPromotionMessagesToDTOs.
@Override
public Map<String, List<PromotionMessageDTO>> convertPromotionMessagesToDTOs(Set<PromotionMessage> promotionMessages, Offer offer) {
MultiValueMap promotionMessageDTOs = new MultiValueMap();
for (PromotionMessage message : promotionMessages) {
PromotionMessageDTO dto = new PromotionMessageDTO(message);
CustomerRuleHolder customerRuleHolder = buildCustomerRuleHolder(offer);
dto.setCustomerRuleHolder(customerRuleHolder);
promotionMessageDTOs.put(dto.getMessagePlacement(), dto);
}
return promotionMessageDTOs;
}
Aggregations