Search in sources :

Example 16 with DiscreteOrderItem

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

the class BroadleafCartController method reconfigure.

/**
 * Takes an order item id and rebuilds the dependant order item tree with the current quantities and options set.
 *
 * If the method was invoked via an AJAX call, it will render the "ajax/configure" template.
 * Otherwise, it will perform a 302 redirect to "/cart/configure"
 *
 * @param request
 * @param response
 * @param model
 * @param orderItemId
 * @throws IOException
 * @throws AddToCartException
 * @throws PricingException
 */
public String reconfigure(HttpServletRequest request, HttpServletResponse response, Model model, Long orderItemId) throws IOException, AddToCartException, PricingException, Exception {
    DiscreteOrderItem orderItem = (DiscreteOrderItem) orderItemService.readOrderItemById(orderItemId);
    Long productId = orderItem.getProduct().getId();
    Product product = catalogService.findProductById(productId);
    ConfigurableOrderItemRequest itemRequest = orderItemService.createConfigurableOrderItemRequestFromProduct(product);
    orderItemService.modifyOrderItemRequest(itemRequest);
    orderItemService.mergeOrderItemRequest(itemRequest, orderItem);
    // update quantities and product options
    itemRequest.setQuantity(orderItem.getQuantity());
    model.addAttribute("baseItem", itemRequest);
    model.addAttribute("isUpdateRequest", Boolean.TRUE);
    model.addAttribute("originalOrderItem", orderItemId);
    model.addAttribute(ALL_PRODUCTS_ATTRIBUTE_NAME, orderItemService.findAllProductsInRequest(itemRequest));
    return isAjaxRequest(request) ? getConfigureView() : getConfigurePageRedirect();
}
Also used : DiscreteOrderItem(org.broadleafcommerce.core.order.domain.DiscreteOrderItem) Product(org.broadleafcommerce.core.catalog.domain.Product) ConfigurableOrderItemRequest(org.broadleafcommerce.core.order.service.call.ConfigurableOrderItemRequest)

Example 17 with DiscreteOrderItem

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

the class ProductOptionDisplayProcessor method populateModelVariables.

@Override
public Map<String, Object> populateModelVariables(String tagName, Map<String, String> tagAttributes, BroadleafTemplateContext context) {
    HashMap<String, String> productOptionDisplayValues = new HashMap<>();
    Object item = context.parseExpression(tagAttributes.get("orderItem"));
    if (item instanceof DiscreteOrderItem) {
        DiscreteOrderItem orderItem = (DiscreteOrderItem) item;
        for (String i : orderItem.getOrderItemAttributes().keySet()) {
            for (ProductOption option : orderItem.getProduct().getProductOptions()) {
                if (option.getAttributeName().equals(i) && !StringUtils.isEmpty(orderItem.getOrderItemAttributes().get(i).toString())) {
                    productOptionDisplayValues.put(option.getLabel(), orderItem.getOrderItemAttributes().get(i).toString());
                }
            }
        }
    }
    return ImmutableMap.of("productOptionDisplayValues", (Object) productOptionDisplayValues);
}
Also used : DiscreteOrderItem(org.broadleafcommerce.core.order.domain.DiscreteOrderItem) ProductOption(org.broadleafcommerce.core.catalog.domain.ProductOption) HashMap(java.util.HashMap)

Example 18 with DiscreteOrderItem

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

the class i18nUpdateCartServiceExtensionHandler method fixTranslations.

protected void fixTranslations(Order cart) {
    for (DiscreteOrderItem orderItem : cart.getDiscreteOrderItems()) {
        Sku sku = orderItem.getSku();
        translateOrderItem(orderItem, sku);
    }
    for (OrderItem orderItem : cart.getOrderItems()) {
        if (orderItem instanceof BundleOrderItem) {
            BundleOrderItem bundleItem = (BundleOrderItem) orderItem;
            Sku sku = bundleItem.getSku();
            translateOrderItem(orderItem, sku);
        }
    }
}
Also used : DiscreteOrderItem(org.broadleafcommerce.core.order.domain.DiscreteOrderItem) BundleOrderItem(org.broadleafcommerce.core.order.domain.BundleOrderItem) DiscreteOrderItem(org.broadleafcommerce.core.order.domain.DiscreteOrderItem) OrderItem(org.broadleafcommerce.core.order.domain.OrderItem) BundleOrderItem(org.broadleafcommerce.core.order.domain.BundleOrderItem) Sku(org.broadleafcommerce.core.catalog.domain.Sku)

Example 19 with DiscreteOrderItem

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

the class OrderItemServiceImpl method createDynamicPriceDiscreteOrderItem.

@Override
public DiscreteOrderItem createDynamicPriceDiscreteOrderItem(final DiscreteOrderItemRequest itemRequest, @SuppressWarnings("rawtypes") HashMap skuPricingConsiderations) {
    final DiscreteOrderItem item = (DiscreteOrderItem) orderItemDao.create(OrderItemType.EXTERNALLY_PRICED);
    populateDiscreteOrderItem(item, itemRequest);
    SkuPriceWrapper wrapper = new SkuPriceWrapper(itemRequest.getSku());
    DynamicSkuPrices prices = dynamicSkuPricingService.getSkuPrices(wrapper, skuPricingConsiderations);
    item.setBundleOrderItem(itemRequest.getBundleOrderItem());
    item.setBaseRetailPrice(prices.getRetailPrice());
    item.setBaseSalePrice(prices.getSalePrice());
    item.setSalePrice(prices.getSalePrice());
    item.setRetailPrice(prices.getRetailPrice());
    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());
    }
    item.setDiscreteOrderItemFeePrices(itemRequest.getDiscreteOrderItemFeePrices());
    for (DiscreteOrderItemFeePrice fee : itemRequest.getDiscreteOrderItemFeePrices()) {
        item.setSalePrice(item.getSalePrice().add(fee.getAmount()));
        item.setRetailPrice(item.getRetailPrice().add(fee.getAmount()));
    }
    item.setPersonalMessage(itemRequest.getPersonalMessage());
    applyAdditionalOrderItemProperties(item);
    return item;
}
Also used : DiscreteOrderItem(org.broadleafcommerce.core.order.domain.DiscreteOrderItem) SkuPriceWrapper(org.broadleafcommerce.core.catalog.domain.pricing.SkuPriceWrapper) DynamicSkuPrices(org.broadleafcommerce.core.catalog.service.dynamic.DynamicSkuPrices) DiscreteOrderItemFeePrice(org.broadleafcommerce.core.order.domain.DiscreteOrderItemFeePrice)

Example 20 with DiscreteOrderItem

use of org.broadleafcommerce.core.order.domain.DiscreteOrderItem 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;
}
Also used : DiscreteOrderItem(org.broadleafcommerce.core.order.domain.DiscreteOrderItem) PromotionMessageGenerator(org.broadleafcommerce.core.promotionMessage.service.PromotionMessageGenerator) PromotionMessageDTO(org.broadleafcommerce.core.promotionMessage.dto.PromotionMessageDTO) ArrayList(java.util.ArrayList) Product(org.broadleafcommerce.core.catalog.domain.Product) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

DiscreteOrderItem (org.broadleafcommerce.core.order.domain.DiscreteOrderItem)57 BundleOrderItem (org.broadleafcommerce.core.order.domain.BundleOrderItem)30 OrderItem (org.broadleafcommerce.core.order.domain.OrderItem)27 Order (org.broadleafcommerce.core.order.domain.Order)19 ArrayList (java.util.ArrayList)18 FulfillmentGroupItem (org.broadleafcommerce.core.order.domain.FulfillmentGroupItem)18 FulfillmentGroup (org.broadleafcommerce.core.order.domain.FulfillmentGroup)17 Sku (org.broadleafcommerce.core.catalog.domain.Sku)16 HashMap (java.util.HashMap)11 OrderItemRequestDTO (org.broadleafcommerce.core.order.service.call.OrderItemRequestDTO)10 Money (org.broadleafcommerce.common.money.Money)9 Product (org.broadleafcommerce.core.catalog.domain.Product)9 DiscreteOrderItemImpl (org.broadleafcommerce.core.order.domain.DiscreteOrderItemImpl)8 Transactional (org.springframework.transaction.annotation.Transactional)8 SkuImpl (org.broadleafcommerce.core.catalog.domain.SkuImpl)7 FulfillmentGroupItemImpl (org.broadleafcommerce.core.order.domain.FulfillmentGroupItemImpl)7 GiftWrapOrderItem (org.broadleafcommerce.core.order.domain.GiftWrapOrderItem)7 FulfillmentGroupImpl (org.broadleafcommerce.core.order.domain.FulfillmentGroupImpl)6 List (java.util.List)5 ProductBundle (org.broadleafcommerce.core.catalog.domain.ProductBundle)5