Package org.broadleafcommerce.core.order.domain

Examples of org.broadleafcommerce.core.order.domain.DiscreteOrderItem


   
    @Override
    public OrderItemRequestDTO buildOrderItemRequestDTOFromOrderItem(OrderItem item) {
        OrderItemRequestDTO orderItemRequest;
        if (item instanceof DiscreteOrderItem) {
            DiscreteOrderItem doi = (DiscreteOrderItem) item;
            orderItemRequest = new OrderItemRequestDTO();
            orderItemRequest.setQuantity(doi.getQuantity());
           
            if (doi.getCategory() != null) {
                orderItemRequest.setCategoryId(doi.getCategory().getId());
            }
           
            if (doi.getProduct() != null) {
                orderItemRequest.setProductId(doi.getProduct().getId());
            }
           
            if (doi.getSku() != null) {
                orderItemRequest.setSkuId(doi.getSku().getId());
            }
           
            if (doi.getOrderItemAttributes() != null) {
                for (Entry<String, OrderItemAttribute> entry : item.getOrderItemAttributes().entrySet()) {
                    orderItemRequest.getItemAttributes().put(entry.getKey(), entry.getValue().getValue());
                }
            }
        } else {
View Full Code Here


                // We first need to save the discrete order items that are part of this bundle. Once they're saved, we'll
                // mark them and remove them from this bundle.
                List<DiscreteOrderItem> doisToAdd = new ArrayList<DiscreteOrderItem>();
                ListIterator<DiscreteOrderItem> li = ((BundleOrderItem) oi ).getDiscreteOrderItems().listIterator();
                while (li.hasNext()) {
                    DiscreteOrderItem doi = li.next();
                    getOiFgiMap(order, oiFgiMap, doi);
                    DiscreteOrderItem savedDoi = (DiscreteOrderItem) orderItemService.saveOrderItem(doi);
                    savedOrderItems.put(doi, savedDoi);
                    li.remove();
                    doisToAdd.add(savedDoi);
                }
               
View Full Code Here

        }
       
        // Throw an exception if the user is trying to update an order item that is part of a bundle
        OrderItem orderItem = orderItemService.readOrderItemById(orderItemRequestDTO.getOrderItemId());
        if (orderItem != null && orderItem instanceof DiscreteOrderItem) {
            DiscreteOrderItem doi = (DiscreteOrderItem) orderItem;
            if (doi.getBundleOrderItem() != null) {
                throw new IllegalArgumentException("Cannot update an item that is part of a bundle");
            }
        }
       
        return context;
View Full Code Here

        if (orderItem == null) {
            throw new IllegalArgumentException("Could not find order item to remove");
        }
       
        if (orderItem != null && orderItem instanceof DiscreteOrderItem) {
            DiscreteOrderItem doi = (DiscreteOrderItem) orderItem;
            if (doi.getBundleOrderItem() != null) {
                throw new IllegalArgumentException("Cannot remove an item that is part of a bundle");
            }
        }
        request.setOrderItem(orderItem);
       
View Full Code Here

        if (customerCart != null) {
            List<OrderItem> itemsToRemove = new ArrayList<OrderItem>();

            for (OrderItem orderItem : customerCart.getOrderItems()) {
                if (orderItem instanceof DiscreteOrderItem) {
                    DiscreteOrderItem doi = (DiscreteOrderItem) orderItem;
                    if (!checkActive(doi) || !checkInventory(doi) || !checkOtherValidity(orderItem)) {
                        itemsToRemove.add(orderItem);
                    }
                } else if (orderItem instanceof BundleOrderItem) {
                    BundleOrderItem bundleOrderItem = (BundleOrderItem) orderItem;
                    for (DiscreteOrderItem doi : bundleOrderItem.getDiscreteOrderItems()) {
                        if (!checkActive(doi) || !checkInventory(doi) || !checkOtherValidity(orderItem)) {
                            itemsToRemove.add(doi.getBundleOrderItem());
                        }
                    }
                }
            }
View Full Code Here

        }
       
        // Throw an exception if the user is trying to update an order item that is part of a bundle
        OrderItem orderItem = orderItemService.readOrderItemById(orderItemRequestDTO.getOrderItemId());
        if (orderItem != null && orderItem instanceof DiscreteOrderItem) {
            DiscreteOrderItem doi = (DiscreteOrderItem) orderItem;
            if (doi.getBundleOrderItem() != null) {
                //then its ok , since we are just updating the product options
            }
        }
       
        return context;
View Full Code Here

        Order customerCart = orderService.findCartForCustomer(customer);
        if (customerCart != null) {
            List<OrderItem> itemsToRemove = new ArrayList<OrderItem>();
            for (OrderItem orderItem : customerCart.getOrderItems()) {
                 if (orderItem instanceof DiscreteOrderItem) {
                    DiscreteOrderItem discreteOrderItem = (DiscreteOrderItem) orderItem;
                    if (discreteOrderItem.getSku().getActiveStartDate() != null) {
                        if (!discreteOrderItem.getSku().isActive(
                                discreteOrderItem.getProduct(),
                                orderItem.getCategory())) {
                            itemsToRemove.add(orderItem);
                        }
                    } else {
                        if (!discreteOrderItem.getProduct().isActive() || !orderItem.getCategory().isActive()) {
                            itemsToRemove.add(orderItem);
                        }
                    }
                } else if (orderItem instanceof BundleOrderItem) {
                    BundleOrderItem bundleOrderItem = (BundleOrderItem) orderItem;
                    boolean removeBundle = false;
                    for (DiscreteOrderItem discreteOrderItem : bundleOrderItem
                            .getDiscreteOrderItems()) {
                        if (discreteOrderItem.getSku().getActiveStartDate() != null) {
                            if (!discreteOrderItem.getSku().isActive(
                                    discreteOrderItem.getProduct(),
                                    orderItem.getCategory())) {
                                /*
                                 * Bundle has an inactive item in it -- remove the
                                 * whole bundle
                                 */
                                removeBundle = true;
                                break;
                            }
                        } else {
                            if (!discreteOrderItem.getProduct().isActive() || !orderItem.getCategory().isActive()) {
                                removeBundle = true;
                                break;
                            }
                        }
                    }
View Full Code Here

                                    newItem.setGiftWrapOrderItem(giftItem);
                                    itemsToAdd.add(newItem);
                                    wrappedItem.setGiftWrapOrderItem(null);
                                    wrappedItems.remove();
                                } else if (wrappedItem instanceof DiscreteOrderItem) {
                                    DiscreteOrderItem discreteWrappedItem = (DiscreteOrderItem) wrappedItem;
                                    String itemKey = discreteWrappedItem.getSku().getId() + "_" + discreteWrappedItem.getPrice();
                                    if (newItemsMap.containsKey(itemKey)) {
                                        OrderItem newItem = newItemsMap.get(itemKey);
                                        newItem.setGiftWrapOrderItem(giftItem);
                                        itemsToAdd.add(newItem);
                                        discreteWrappedItem.setGiftWrapOrderItem(null);
                                        wrappedItems.remove();
                                    } else {
                                        isValidBundle = false;
                                        break checkBundle;
                                    }
View Full Code Here

        // currently we'll just add items
        for (OrderItem orderItem : anonymousCart.getOrderItems()) {
            if (orderItem instanceof DiscreteOrderItem) {
                orderItem.removeAllAdjustments();
                orderItem.removeAllCandidateItemOffers();
                DiscreteOrderItem discreteOrderItem = (DiscreteOrderItem) orderItem;
                if (discreteOrderItem.getSku().getActiveStartDate() != null) {
                    if (discreteOrderItem.getSku().isActive(discreteOrderItem.getProduct(), orderItem.getCategory())) {
                        OrderItem newItem = addOrderItemToOrder(customerCart, discreteOrderItem.clone(), false);
                        mergeCartResponse.getAddedItems().add(newItem);
                        oldNewItemMap.put(orderItem, newItem);
                    } else {
                        mergeCartResponse.getRemovedItems().add(orderItem);
                    }
                } else {
                    if (discreteOrderItem.getProduct().isActive() && orderItem.getCategory().isActive()) {
                        OrderItem newItem = addOrderItemToOrder(customerCart, discreteOrderItem.clone(), false);
                        mergeCartResponse.getAddedItems().add(newItem);
                        oldNewItemMap.put(orderItem, newItem);
                    } else {
                        mergeCartResponse.getRemovedItems().add(orderItem);
                    }
                }
            } else if (orderItem instanceof BundleOrderItem) {
                BundleOrderItem bundleOrderItem = (BundleOrderItem) orderItem;
                orderItem.removeAllAdjustments();
                orderItem.removeAllCandidateItemOffers();
                boolean removeBundle = false;
                for (DiscreteOrderItem discreteOrderItem : bundleOrderItem.getDiscreteOrderItems()){
                    discreteOrderItem.removeAllAdjustments();
                    discreteOrderItem.removeAllCandidateItemOffers();
                    if (discreteOrderItem.getSku().getActiveStartDate() != null) {
                        if (!discreteOrderItem.getSku().isActive(discreteOrderItem.getProduct(), orderItem.getCategory())) {
                            /*
                             * Bundle has an inactive item in it -- remove the whole bundle
                             */
                            removeBundle = true;
                        }
                    } else {
                        if (!discreteOrderItem.getProduct().isActive() || !orderItem.getCategory().isActive()) {
                            removeBundle = true;
                        }
                    }
                }
                if (!removeBundle) {
View Full Code Here

                    if (unbundledItems == null) {
                        unbundledItems = new ArrayList<DiscreteOrderItem>();
                    }

                    for(DiscreteOrderItem item : bundleOrderItem.getDiscreteOrderItems()) {
                        DiscreteOrderItem newOrderItem = (DiscreteOrderItem) item.clone();
                        newOrderItem.setQuantity(item.getQuantity() * bundleOrderItem.getQuantity());
                        newOrderItem.setSkuBundleItem(null);
                        newOrderItem.setBundleOrderItem(null);  
                        newOrderItem.updateSaleAndRetailPrices();
                        newOrderItem.setOrder(order);
                        unbundledItems.add(newOrderItem);
                    }
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.broadleafcommerce.core.order.domain.DiscreteOrderItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.