Package org.broadleafcommerce.core.order.domain

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


        OrderItemRequestDTO itemRequest = new OrderItemRequestDTO();
        itemRequest.setQuantity(1);
        itemRequest.setSkuId(sku.getId());
        order = orderService.addItem(orderId, itemRequest, true);
       
        DiscreteOrderItem item = (DiscreteOrderItem) orderService.findLastMatchingItem(order, sku.getId(), null);
       
        assert item != null;
        assert item.getQuantity() == numOrderItems;
        assert item.getSku() != null;
        assert item.getSku().equals(sku);
       
        assert order.getFulfillmentGroups().size() == 1;
       
        FulfillmentGroup fg = order.getFulfillmentGroups().get(0);
        assert fg.getFulfillmentGroupItems().size() == 1;
       
        FulfillmentGroupItem fgItem = fg.getFulfillmentGroupItems().get(0);
        assert fgItem.getOrderItem().equals(item);
        assert fgItem.getQuantity() == item.getQuantity();
    }
View Full Code Here


        OrderItemRequestDTO itemRequest = new OrderItemRequestDTO();
        itemRequest.setQuantity(1);
        itemRequest.setSkuId(sku.getId());
        // Note that we are not incrementing the numOrderItems count because it should have gotten merged
        order = orderService.addItem(orderId, itemRequest, true);
        DiscreteOrderItem item = (DiscreteOrderItem) orderService.findLastMatchingItem(order, sku.getId(), null);
       
        assert item.getSku() != null;
        assert item.getSku().equals(sku);
        assert item.getQuantity() == 2// item-was merged with prior item.

        order = orderService.findOrderById(orderId);

        assert(order.getOrderItems().size()==1);
        assert(order.getOrderItems().get(0).getQuantity()==2);
       
        assert order.getFulfillmentGroups().size() == 1;
       
        FulfillmentGroup fg = order.getFulfillmentGroups().get(0);
        assert fg.getFulfillmentGroupItems().size() == 1;
       
        FulfillmentGroupItem fgItem = fg.getFulfillmentGroupItems().get(0);
        assert fgItem.getOrderItem().equals(item);
        assert fgItem.getQuantity() == item.getQuantity();

        /*
        This test is not supported currently, as the order service may only do like item merging

        // re-price the order without automatically merging.
View Full Code Here

        xref2.setProduct(product2);
        xref2.setCategory(category2);
       
        category2.getAllProductXrefs().add(xref2);
       
        DiscreteOrderItem orderItem1 = new DiscreteOrderItemImpl();
        orderItem1.setCategory(category1);
        orderItem1.setName("test1");
        orderItem1.setOrder(order);
        orderItem1.setOrderItemType(OrderItemType.DISCRETE);
        orderItem1.setProduct(product1);
        orderItem1.setQuantity(2);
        orderItem1.setSku(sku1);
        orderItem1.setId(getOrderItemId());
        orderItem1.setOrder(order);
       
        OrderItemPriceDetail priceDetail1 = new OrderItemPriceDetailImpl();
        priceDetail1.setOrderItem(orderItem1);
        priceDetail1.setQuantity(2);
        orderItem1.getOrderItemPriceDetails().add(priceDetail1);
       
        order.getOrderItems().add(orderItem1);
       
        DiscreteOrderItem orderItem2 = new DiscreteOrderItemImpl();
        orderItem2.setCategory(category2);
        orderItem2.setName("test2");
        orderItem2.setOrder(order);
        orderItem2.setOrderItemType(OrderItemType.DISCRETE);
        orderItem2.setProduct(product2);
        orderItem2.setQuantity(3);
        orderItem2.setSku(sku2);
        orderItem2.setId(getOrderItemId());
        orderItem2.setOrder(order);
       
        OrderItemPriceDetail priceDetail2 = new OrderItemPriceDetailImpl();
        priceDetail2.setOrderItem(orderItem2);
        priceDetail2.setQuantity(3);
        orderItem2.getOrderItemPriceDetails().add(priceDetail2);
       
        order.getOrderItems().add(orderItem2);
       
        Customer customer = new CustomerImpl();
        customer.setEmailAddress("test@test.com");
View Full Code Here

        priceDetail.setQuantity(2);
        bundleOrderItem.getOrderItemPriceDetails().add(priceDetail);

        order.getOrderItems().add(bundleOrderItem);

        DiscreteOrderItem orderItem1 = new DiscreteOrderItemImpl();
        orderItem1.setCategory(category1);
        orderItem1.setName("test1");
        orderItem1.setOrder(order);
        orderItem1.setOrderItemType(OrderItemType.DISCRETE);
        orderItem1.setProduct(product1);
        orderItem1.setQuantity(2);
        orderItem1.setSku(sku1);
        orderItem1.setId(getOrderItemId());
        orderItem1.setOrder(order);

        OrderItemPriceDetail priceDetail1 = new OrderItemPriceDetailImpl();
        priceDetail1.setOrderItem(orderItem1);
        priceDetail1.setQuantity(2);
        orderItem1.getOrderItemPriceDetails().add(priceDetail1);

        bundleOrderItem.getDiscreteOrderItems().add(orderItem1);

        DiscreteOrderItem orderItem2 = new DiscreteOrderItemImpl();
        orderItem2.setCategory(category2);
        orderItem2.setName("test2");
        orderItem2.setOrder(order);
        orderItem2.setOrderItemType(OrderItemType.DISCRETE);
        orderItem2.setProduct(product2);
        orderItem2.setQuantity(3);
        orderItem2.setSku(sku2);
        orderItem2.setId(getOrderItemId());
        orderItem2.setOrder(order);

        OrderItemPriceDetail priceDetail2 = new OrderItemPriceDetailImpl();
        priceDetail2.setOrderItem(orderItem2);
        priceDetail2.setQuantity(3);
        orderItem2.getOrderItemPriceDetails().add(priceDetail2);

        bundleOrderItem.getDiscreteOrderItems().add(orderItem2);

        Customer customer = new CustomerImpl();
        customer.setEmailAddress("test@test.com");
View Full Code Here

            }
            sb.append("]);");

            for (FulfillmentGroup fulfillmentGroup : order.getFulfillmentGroups()) {
                for (FulfillmentGroupItem fulfillmentGroupItem : fulfillmentGroup.getFulfillmentGroupItems()) {
                    DiscreteOrderItem orderItem = (DiscreteOrderItem) fulfillmentGroupItem.getOrderItem();
                    sb.append("_gaq.push(['_addItem','" + order.getId() + "'");
                    sb.append(",'" + orderItem.getSku().getId() + "'");
                    sb.append(",'" + orderItem.getSku().getName() + "'");
                    sb.append(",' " + orderItem.getProduct().getDefaultCategory() + "'");
                    sb.append(",'" + orderItem.getPrice() + "'");
                    sb.append(",'" + orderItem.getQuantity() + "'");
                    sb.append("]);");
                }
            }
            sb.append("_gaq.push(['_trackTrans']);");
        }
View Full Code Here

        order.setFulfillmentGroups(groups);
        Money total = new Money(5D);
        group.setRetailShippingPrice(total);
        group.setShippingPrice(total);

        DiscreteOrderItem item1;
        {
        item1 = new DiscreteOrderItemImpl();
        Sku sku = new SkuImpl();
        sku.setName("Test Sku");
        sku.setRetailPrice(new Money(10D));
        sku.setDiscountable(true);

        sku = catalogService.saveSku(sku);

        item1.setSku(sku);
        item1.setQuantity(2);
        item1.setOrder(order);
        item1.setOrderItemType(OrderItemType.DISCRETE);

        item1 = (DiscreteOrderItem) orderItemService.saveOrderItem(item1);

        order.addOrderItem(item1);
        FulfillmentGroupItem fgItem = new FulfillmentGroupItemImpl();
        fgItem.setFulfillmentGroup(group);
        fgItem.setOrderItem(item1);
        fgItem.setQuantity(2);
        //fgItem.setPrice(new Money(0D));
        group.addFulfillmentGroupItem(fgItem);
        }

        {
        DiscreteOrderItem item = new DiscreteOrderItemImpl();
        Sku sku = new SkuImpl();
        sku.setName("Test Product 2");
        sku.setRetailPrice(new Money(20D));
        sku.setDiscountable(true);

        sku = catalogService.saveSku(sku);

        item.setSku(sku);
        item.setQuantity(1);
        item.setOrder(order);
        item.setOrderItemType(OrderItemType.DISCRETE);

        item = (DiscreteOrderItem) orderItemService.saveOrderItem(item);

        order.addOrderItem(item);

        FulfillmentGroupItem fgItem = new FulfillmentGroupItemImpl();
        fgItem.setFulfillmentGroup(group);
        fgItem.setOrderItem(item);
        fgItem.setQuantity(1);
        //fgItem.setPrice(new Money(0D));
        group.addFulfillmentGroupItem(fgItem);
        }

        {
        GiftWrapOrderItem item = new GiftWrapOrderItemImpl();
        Sku sku = new SkuImpl();
        sku.setName("Test GiftWrap");
        sku.setRetailPrice(new Money(1D));
        sku.setDiscountable(true);

        sku = catalogService.saveSku(sku);

        item.setSku(sku);
        item.setQuantity(1);
        item.setOrder(order);
        item.getWrappedItems().add(item1);
        item.setOrderItemType(OrderItemType.GIFTWRAP);

        item = (GiftWrapOrderItem) orderItemService.saveOrderItem(item);

        order.addOrderItem(item);
View Full Code Here

        Order result = new OrderImpl();

        List<FulfillmentGroupItem> fulfillmentItems = new ArrayList<FulfillmentGroupItem>();
        for (int i = 0; i < orderItemsToCreate; i++) {
            DiscreteOrderItem orderItem = new DiscreteOrderItemImpl();
            Sku sku = new SkuImpl();
            //set the sku price to some arbitrary amount - won't matter because the test is based on order item price
            sku.setRetailPrice(new Money("1"));
            orderItem.setSku(sku);

            if (flatRates != null && i < flatRates.length) {
                sku.getFulfillmentFlatRates().put(option, new BigDecimal(flatRates[i]));
            }

            if (option instanceof BandedPriceFulfillmentOption) {
                orderItem.setPrice(new Money(total.divide(new BigDecimal(orderItemsToCreate))));
            } else if (option instanceof BandedWeightFulfillmentOption) {
                Weight weight = new Weight();
                weight.setWeight(total.divide(new BigDecimal(orderItemsToCreate)));
                weight.setWeightUnitOfMeasure(WeightUnitOfMeasureType.POUNDS);
                orderItem.getSku().setWeight(weight);
                orderItem.setPrice(new Money(BigDecimal.ZERO));
            }
            orderItem.setOrder(result);

            FulfillmentGroupItem fulfillmentItem = new FulfillmentGroupItemImpl();
            fulfillmentItem.setOrderItem(orderItem);
            if (quantities == null) {
                fulfillmentItem.setQuantity(1);
View Full Code Here

        order.setFulfillmentGroups(groups);
        Money total = new Money(5D);
        group.setRetailShippingPrice(total);
        group.setShippingPrice(total);

        DiscreteOrderItem item1;
        {
        item1 = new DiscreteOrderItemImpl();
        Sku sku = new SkuImpl();
        sku.setName("Test Sku");
        sku.setRetailPrice(new Money(10D));
        sku.setDiscountable(true);

        sku = catalogService.saveSku(sku);

        item1.setSku(sku);
        item1.setQuantity(2);
        item1.setOrder(order);
        item1.setOrderItemType(OrderItemType.DISCRETE);

        item1 = (DiscreteOrderItem) orderItemService.saveOrderItem(item1);

        order.addOrderItem(item1);
        FulfillmentGroupItem fgItem = new FulfillmentGroupItemImpl();
        fgItem.setFulfillmentGroup(group);
        fgItem.setOrderItem(item1);
        fgItem.setQuantity(2);
        //fgItem.setPrice(new Money(0D));
        group.addFulfillmentGroupItem(fgItem);
        }

        {
        DiscreteOrderItem item = new DiscreteOrderItemImpl();
        Sku sku = new SkuImpl();
        sku.setName("Test Product 2");
        sku.setRetailPrice(new Money(20D));
        sku.setDiscountable(true);

        sku = catalogService.saveSku(sku);

        item.setSku(sku);
        item.setQuantity(1);
        item.setOrder(order);
        item.setOrderItemType(OrderItemType.DISCRETE);

        item = (DiscreteOrderItem) orderItemService.saveOrderItem(item);

        order.addOrderItem(item);

        FulfillmentGroupItem fgItem = new FulfillmentGroupItemImpl();
        fgItem.setFulfillmentGroup(group);
        fgItem.setOrderItem(item);
        fgItem.setQuantity(1);
        //fgItem.setPrice(new Money(0D));
        group.addFulfillmentGroupItem(fgItem);
        }

        {
        GiftWrapOrderItem item = new GiftWrapOrderItemImpl();
        Sku sku = new SkuImpl();
        sku.setName("Test GiftWrap");
        sku.setRetailPrice(new Money(1D));
        sku.setDiscountable(true);

        sku = catalogService.saveSku(sku);

        item.setSku(sku);
        item.setQuantity(1);
        item.setOrder(order);
        item.getWrappedItems().add(item1);
        item.setOrderItemType(OrderItemType.GIFTWRAP);

        item = (GiftWrapOrderItem) orderItemService.saveOrderItem(item);

        order.addOrderItem(item);
View Full Code Here

        Map<String, Object> newVars = new HashMap<String, Object>();
        Expression expression = (Expression) StandardExpressions.getExpressionParser(arguments.getConfiguration())
                .parseExpression(arguments.getConfiguration(), arguments, element.getAttributeValue("orderItem"));
        Object item = expression.execute(arguments.getConfiguration(), arguments);
        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());
                    }
                }
            }
        }
        newVars.put("productOptionDisplayValues", productOptionDisplayValues);
View Full Code Here

                this.orderItemPriceDetails.add(orderItemPriceDetailWrapper);
            }
        }
       
        if (model instanceof DiscreteOrderItem) {
            DiscreteOrderItem doi = (DiscreteOrderItem) model;
            this.skuId = doi.getSku().getId();
            this.productId = doi.getProduct().getId();
            this.isBundle = false;
            this.isDiscountingAllowed = doi.isDiscountingAllowed();
        } else if (model instanceof BundleOrderItem) {
            BundleOrderItem boi = (BundleOrderItem) model;
            this.skuId = boi.getSku().getId();
            this.productId = boi.getProduct().getId();
            this.isBundle = true;
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.